Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.order.component.js 521KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Apps;
  4. (function (Apps) {
  5. let Transact;
  6. (function (Transact) {
  7. let Infos;
  8. (function (Infos) {
  9. class OrderItem {
  10. static Instance() {
  11. if (this.instance === undefined) {
  12. this.instance = new OrderItem();
  13. }
  14. return this.instance;
  15. }
  16. }
  17. Infos.OrderItem = OrderItem;
  18. class FoCItem {
  19. }
  20. Infos.FoCItem = FoCItem;
  21. class ValidOrderFoCItem {
  22. }
  23. Infos.ValidOrderFoCItem = ValidOrderFoCItem;
  24. class AppliedOffer {
  25. }
  26. Infos.AppliedOffer = AppliedOffer;
  27. class OrderTotals {
  28. }
  29. Infos.OrderTotals = OrderTotals;
  30. class UOMSchemaDetails {
  31. }
  32. Infos.UOMSchemaDetails = UOMSchemaDetails;
  33. class POSOrderItem {
  34. static Instance() {
  35. if (this.instance === undefined) {
  36. this.instance = new OrderItem();
  37. }
  38. return this.instance;
  39. }
  40. }
  41. Infos.POSOrderItem = POSOrderItem;
  42. class Cart_Item {
  43. static Instance() {
  44. if (this.instance === undefined) {
  45. this.instance = new Cart_Item();
  46. }
  47. return this.instance;
  48. }
  49. }
  50. Infos.Cart_Item = Cart_Item;
  51. class ValidFoCItem {
  52. }
  53. Infos.ValidFoCItem = ValidFoCItem;
  54. class RawMaterial {
  55. }
  56. Infos.RawMaterial = RawMaterial;
  57. class Operation {
  58. }
  59. Infos.Operation = Operation;
  60. })(Infos = Transact.Infos || (Transact.Infos = {}));
  61. })(Transact = Apps.Transact || (Apps.Transact = {}));
  62. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  63. })(Bizgaze || (Bizgaze = {}));
  64. var Bizgaze;
  65. (function (Bizgaze) {
  66. let Apps;
  67. (function (Apps) {
  68. let Transact;
  69. (function (Transact) {
  70. let Components;
  71. (function (Components) {
  72. class OrderFilter extends Unibase.Platform.Core.BaseComponent {
  73. constructor() {
  74. super(...arguments);
  75. this.g_TagArray = [];
  76. this.g_ClearingTags = "";
  77. this.g_ContainerId = "";
  78. this.g_Tags = "";
  79. this.g_OnlyFilters = false;
  80. this.g_TagCategoryId = 0;
  81. this.g_LobId = 0;
  82. }
  83. cssFiles() {
  84. return [];
  85. }
  86. jsFiles() {
  87. var jsFiles = ['apps/crm/lobs/managers/lobmanager.js', 'apps/transact/managers/inventory/itemmanager.js'];
  88. return jsFiles;
  89. }
  90. html(id, containerid) {
  91. var instance = this;
  92. instance.g_ContainerId = containerid;
  93. var html = `<header class="b-b bg-white modal-header pt-10 pb-10">
  94. <strong class="text-dark titlename">Filters</strong>
  95. <div class="btn-group ml-auto"> <a class="btn btn-sm"><i class="ti-help-alt" title="help" href="" target="_blank"></i></a></div>
  96. </header>
  97. <div style="overflow-x:hidden;" class="scrollable">
  98. <div class="card">
  99. <div class="card-body">
  100. <div class="divTagList"></div>
  101. </div>
  102. </div>
  103. </div>
  104. <footer class="bg-white modal-footer pt-10 pb-10">
  105. <a href="javascript:;" id="btn_CancelFilter" class="btn btn-light btn-sm mr-auto"> Close </a>
  106. <a href="javascript:;" id="btn_ApplyFilter" class="btn btn-primary btn-sm">Apply</a>
  107. <a href="javascript:;" id="btn_ClearFilter" class="btn btn-primary btn-sm">Clear</a>
  108. </footer>`;
  109. return html;
  110. }
  111. load(id, containerid, callback) {
  112. var instance = this;
  113. instance.g_LobId = Number($(".txtAutoComplete_LobId").val());
  114. instance.categoryTagItem();
  115. if (id == "POS") {
  116. instance.g_order = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance();
  117. instance.g_orderItem = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance();
  118. }
  119. else {
  120. instance.g_order = Bizgaze.Apps.Transact.Controls.Order.Instance();
  121. instance.g_orderItem = Bizgaze.Apps.Transact.Controls.OrderItems.Instance();
  122. }
  123. if (isNaN(instance.g_LobId)) {
  124. instance.g_LobId = instance.g_order.g_LobId;
  125. }
  126. $('#btn_CancelFilter').click(function () {
  127. for (var i = 0; i < instance.g_TagArray.length; i++) {
  128. instance.g_ClearingTags += instance.g_TagArray[i].TagId + "|";
  129. }
  130. instance.g_ClearingTags = instance.g_ClearingTags.replace(/\:$/, '');
  131. instance.g_Tags = instance.g_ClearingTags;
  132. instance.filterItemsByTags(instance.g_ClearingTags, false);
  133. });
  134. $('#btn_ClearFilter').click(function () {
  135. instance.g_orderItem.g_IsFilterApplied = false;
  136. instance.g_orderItem.g_FilteredTags = '';
  137. instance.clearAll();
  138. });
  139. $('#btn_ApplyFilter').click(function () {
  140. instance.g_orderItem.g_IsFilterApplied = true;
  141. instance.showFilteredItems();
  142. });
  143. }
  144. bindCustomerTags(id = "") {
  145. var instance = this;
  146. if (id == "POS") {
  147. instance.g_order = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance();
  148. instance.g_orderItem = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance();
  149. }
  150. else {
  151. instance.g_order = Bizgaze.Apps.Transact.Controls.Order.Instance();
  152. instance.g_orderItem = Bizgaze.Apps.Transact.Controls.OrderItems.Instance();
  153. }
  154. var TagGroupId = instance.g_order.g_TagGroupId;
  155. var OrganizationId = instance.g_order.g_OrganizationId;
  156. Unibase.Platform.Forms.Managers.TagManager.Instance().GetTagsByRefId(OrganizationId, TagGroupId).then(function (response) {
  157. var data = response.result;
  158. var options = '';
  159. var tags = '';
  160. instance.g_TagArray = [];
  161. for (var i = 0; i < data.length; i++) {
  162. if (data[i] != undefined) {
  163. instance.g_TagArray.push({ TagId: data[i].TagId, TagName: data[i].TagName, ParentId: data[i].ParentRootId });
  164. options += data[i].TagId + "|";
  165. }
  166. }
  167. if (options != '') {
  168. options = options.replace(/\|$/, '');
  169. tags = options;
  170. }
  171. if (tags != '') {
  172. tags = tags.replace(/\:$/, '');
  173. }
  174. instance.g_Tags = tags;
  175. instance.filterItemsByTags(tags, true);
  176. if (Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_TagArray.length != 0) {
  177. $("#ItemLoadType option[value='1']").remove();
  178. instance.g_OnlyFilters = true;
  179. }
  180. });
  181. }
  182. addTagItem(TagGroupId) {
  183. var instance = this;
  184. if (TagGroupId != 0) {
  185. Unibase.Platform.Forms.Managers.TagManager.Instance().getTagParentsByCategoryId(Number(instance.g_TagCategoryId), TagGroupId).then(function (response) {
  186. var taghtml = '';
  187. var disabled = "";
  188. if (Bizgaze.Apps.Transact.Components.OrderFilter.Instance().g_OnlyFilters) {
  189. disabled = "disabled";
  190. $("#btn_ApplyOrderFilter, #btn_ClearOrderFilter").addClass("hidden");
  191. }
  192. for (var i = 0; i < response.result.length; i++) {
  193. var tagName = response.result[i].TagName;
  194. if (i % 2 == 0) {
  195. taghtml += '<div class="row"><div class="col-sm-12">';
  196. }
  197. taghtml += '<div class="col-sm-6 lobTagItems">';
  198. taghtml += '<div class="floating-label-form-group floating-label-form-group-with-value no-border" style="border-bottom:0;"><label>' + tagName + '</label>' +
  199. '<select multiple="multiple" style="width:100%" class="txtTagsSelect2_' + i + ' " id="txtBizgazeNotifications_Tags_' + i + '" data-id=' + i + ' ' + disabled + ' > </select>' +
  200. '<input type="hidden" class="hfTagCloud_ParentTagId-' + i + '" value="' + response.result[i].TagId + '" />' +
  201. '</div></div>';
  202. if (i % 2 == 1) {
  203. taghtml += '</div></div>';
  204. }
  205. }
  206. if (response.result.length == 0) {
  207. taghtml += '' + '<h5><span">No Tags Assigned For This Lob.</span></h5>';
  208. }
  209. $('.divTagList').html(taghtml);
  210. if (response.result.length != 0) {
  211. instance.refreshTags();
  212. }
  213. });
  214. }
  215. }
  216. refreshTags() {
  217. var instance = this;
  218. var y = 0;
  219. var lobid = $(".txtAutoComplete_lobid").val();
  220. var categoryId = instance.g_TagCategoryId;
  221. var PARENTID = "";
  222. let serviceurl = "apis/v4/unibase/platform/forms/autotagsforassignment";
  223. serviceurl = _appsettings.server_url() + (serviceurl.startsWith('/') ? serviceurl : ('/' + serviceurl));
  224. $(".lobTagItems").each(function () {
  225. var parentId = $(this).find(".hfTagCloud_ParentTagId-" + y).val();
  226. PARENTID += parentId + ",";
  227. if (parentId != undefined) {
  228. var Tags = [];
  229. var Ids = [];
  230. if (instance.g_TagArray != undefined && instance.g_TagArray != '') {
  231. for (var i = 0; i < instance.g_TagArray.length; i++) {
  232. var Tag = instance.g_TagArray[i];
  233. if (parentId == Tag.ParentId) {
  234. Tags.push({ id: Tag.TagId, text: Tag.TagName });
  235. Ids.push(Tag.TagId);
  236. }
  237. }
  238. }
  239. var Parameters = [
  240. { ColumnName: 'LobId', Value: lobid },
  241. { ColumnName: 'CategoryId', Value: categoryId },
  242. { ColumnName: 'ParentId', Value: PARENTID },
  243. ];
  244. var ColumnName = "", Value = "";
  245. if (Parameters != null) {
  246. ColumnName = Parameters.map(function (item) { return item.ColumnName; }).toString();
  247. Value = Parameters.map(function (item) { return item.Value + "|"; }).toString();
  248. }
  249. $(".txtTagsSelect2_" + y).select2({
  250. placeholder: "Select",
  251. data: Tags,
  252. ajax: {
  253. url: serviceurl,
  254. contentType: 'application/json',
  255. dataType: 'json',
  256. type: "POST",
  257. traditional: true,
  258. crossDomain: true,
  259. async: true,
  260. data: function (params) {
  261. var y = $(this).attr("id").replace("txtBizgazeNotifications_Tags_", "");
  262. parentId = $(".hfTagCloud_ParentTagId-" + y).val();
  263. var ParticipantsCount = new Array();
  264. var Participants = "";
  265. if ($(".txtTagsSelect2_" + Number($(this).attr('data-id'))).val().toString() != "") {
  266. var Participant = $(".txtTagsSelect2_" + Number($(this).attr('data-id'))).val().toString();
  267. ParticipantsCount = Participant.split(',');
  268. for (var i = 0; i < ParticipantsCount.length; i++) {
  269. Participants += "|" + ParticipantsCount[i];
  270. }
  271. Participants;
  272. }
  273. var Term = params.term != undefined ? params.term : "";
  274. var postData = {
  275. DocPropertyId: 0,
  276. ColumnName: ColumnName,
  277. FormPropertyId: Number($(this).attr('data-id')),
  278. Value: Value,
  279. bindedData: Participants.substring(1, Participants.length),
  280. term: Term,
  281. TagGroupId: Number(instance.g_order.g_TagGroupId),
  282. TagCatagoryId: Number(categoryId),
  283. TagId: Number(parentId),
  284. };
  285. return JSON.stringify(postData);
  286. },
  287. processResults: function (data) {
  288. var json_data = JSON.parse(data.result);
  289. var cols = [];
  290. for (let i = 0; i < json_data.length; i++) {
  291. var ids = {
  292. id: json_data[i].Value,
  293. text: json_data[i].DisplayText
  294. };
  295. cols.push(ids);
  296. }
  297. return { results: cols };
  298. },
  299. beforeSend: function (xhr) {
  300. if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser() !== undefined && Unibase.Platform.Membership.Infos.Identity.getCurrentUser() !== null) {
  301. xhr.setRequestHeader('Authorization', 'Basic ' + Unibase.Platform.Membership.Infos.Identity.getCurrentUser().sessionId);
  302. xhr.setRequestHeader('geoposition', Unibase.Platform.Membership.Infos.Identity.getCurrentUser().latd + ':' + Unibase.Platform.Membership.Infos.Identity.getCurrentUser().lgId);
  303. }
  304. },
  305. },
  306. });
  307. jQuery(".txtTagsSelect2_" + y).val(Ids).trigger('change');
  308. }
  309. y++;
  310. });
  311. y = 0;
  312. }
  313. categoryTagItem() {
  314. var instance = this;
  315. Unibase.Platform.Forms.Managers.TagManager.Instance().getTagCategoryByName("Items").then(function (response) {
  316. var data = response.result;
  317. instance.g_TagCategoryId = data.TagCategoryId;
  318. var TagGroupId = instance.g_order.g_TagGroupId;
  319. if (TagGroupId != null && TagGroupId != 0) {
  320. instance.addTagItem(TagGroupId);
  321. }
  322. });
  323. }
  324. showFilteredItems() {
  325. var instance = this;
  326. var tags = '';
  327. var select2Id = 0;
  328. instance.g_TagArray = [];
  329. $(".lobTagItems").each(function () {
  330. var data = $(this).find('#txtBizgazeNotifications_Tags_' + select2Id + '').select2('data');
  331. var parentId = $(this).find(".hfTagCloud_ParentTagId-" + select2Id).val();
  332. if (data.length > 0) {
  333. var options = '';
  334. for (var i = 0; i < data.length; i++) {
  335. if (data[i] != '000' && data[i] != undefined) {
  336. instance.g_TagArray.push({ TagId: data[i].id, TagName: data[i].text, ParentId: parentId });
  337. options += data[i].id + "|";
  338. }
  339. }
  340. if (options != '') {
  341. options = options.replace(/\|$/, '');
  342. tags += options + "|";
  343. }
  344. }
  345. select2Id++;
  346. });
  347. if (tags != '') {
  348. tags = tags.replace(/\:$/, '');
  349. }
  350. instance.g_Tags = tags;
  351. instance.filterItemsByTags(tags, false);
  352. }
  353. clearAll() {
  354. var select2Id = 0;
  355. $(".lobTagItems").each(function () {
  356. $(this).find('#txtBizgazeNotifications_Tags_' + select2Id + '').val(null).trigger('change');
  357. select2Id++;
  358. });
  359. }
  360. filterItemsByTags(Tags, Ispagination) {
  361. var instance = this;
  362. instance.g_order.g_LoadOffersOnly = false;
  363. if (Tags == "" || Tags == null || Tags == undefined) {
  364. if (instance.g_order.g_IsPurchasePlanning)
  365. instance.g_orderItem.loadPurchasePlanItems('');
  366. else
  367. instance.g_orderItem.loadItems($("#txt_SearchItem").val());
  368. if (instance.g_ContainerId != "") {
  369. if ($('#' + instance.g_ContainerId).length > 0) {
  370. $('#' + instance.g_ContainerId).modal('hide');
  371. }
  372. }
  373. $("#ItemLoadType").val(1);
  374. if (!Ispagination) {
  375. $('#' + instance.g_ContainerId).modal('hide');
  376. $('#' + instance.g_ContainerId).remove();
  377. }
  378. }
  379. else {
  380. var SearchTerm = $("#txt_SearchItem").val();
  381. if (SearchTerm == "")
  382. SearchTerm = null;
  383. instance.g_orderItem.g_FilteredTags = Tags;
  384. var contactId = instance.g_order.g_OrganizationId;
  385. if (contactId == 0)
  386. contactId = instance.g_order.g_OrgContactId;
  387. instance.fileCacheHelper.loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () {
  388. instance.g_Tags = Tags;
  389. instance.g_orderItem.loadItems($("#txt_SearchItem").val());
  390. $("#ItemLoadType").append('<option disabled="disabled" value="0" selected="selected" style="display:none;">Filter</option>');
  391. $("#ItemLoadType").val(0);
  392. if (!Ispagination) {
  393. $('#' + instance.g_ContainerId).modal('hide');
  394. $('#' + instance.g_ContainerId).remove();
  395. }
  396. });
  397. }
  398. }
  399. static Instance() {
  400. if (this.instance === undefined) {
  401. this.instance = new OrderFilter();
  402. }
  403. return this.instance;
  404. }
  405. }
  406. Components.OrderFilter = OrderFilter;
  407. })(Components = Transact.Components || (Transact.Components = {}));
  408. })(Transact = Apps.Transact || (Apps.Transact = {}));
  409. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  410. })(Bizgaze || (Bizgaze = {}));
  411. var Unibase;
  412. (function (Unibase) {
  413. let Platform;
  414. (function (Platform) {
  415. let Helpers;
  416. (function (Helpers) {
  417. class PrintHelper {
  418. printPopup(PrintHtml) {
  419. if (isMobileApp()) {
  420. Unibase.Platform.Helpers.MobileHelper.Instance().previewHtml(PrintHtml);
  421. }
  422. else {
  423. var mywindow = window.open('', 'my Print', 'height=400,width=850');
  424. 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>';
  425. content += PrintHtml;
  426. content += "<script>print();</script>";
  427. content += '</body></html>';
  428. mywindow.document.write(content);
  429. }
  430. return true;
  431. }
  432. showPrintErrorModal() {
  433. bootbox.alert("Please configure print template");
  434. }
  435. static Instance() {
  436. if (this.instance === null || this.instance === undefined)
  437. this.instance = new PrintHelper();
  438. return this.instance;
  439. }
  440. }
  441. Helpers.PrintHelper = PrintHelper;
  442. })(Helpers = Platform.Helpers || (Platform.Helpers = {}));
  443. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  444. })(Unibase || (Unibase = {}));
  445. var Bizgaze;
  446. (function (Bizgaze) {
  447. let Apps;
  448. (function (Apps) {
  449. let Transact;
  450. (function (Transact) {
  451. let Components;
  452. (function (Components) {
  453. let Invoices;
  454. (function (Invoices) {
  455. class ItemOfferSelection extends Unibase.Platform.Core.BaseComponent {
  456. constructor() {
  457. super(...arguments);
  458. this.Bizgaze_Transact_Selected_Plan = new Array();
  459. this.g_Selected_Plan = new Array();
  460. this.OfferIds = [];
  461. }
  462. jsFiles() {
  463. return ['platform/core/helpers/numberhelper/numberhelper.js', 'apps/transact/managers/invoicemanager.js', 'apps/transact/controls/invoices/pos.component.js'];
  464. }
  465. cssFiles() {
  466. return [];
  467. }
  468. html() {
  469. 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>';
  470. return html;
  471. }
  472. load(item) {
  473. var instance = this;
  474. instance.Bizgaze_Transact_Selected_Plan = new Array();
  475. $(".btn_close").click(function () {
  476. instance.navigationHelper.closePopUp();
  477. });
  478. }
  479. PlanSelection(Volume, value, DiscountType, PlanVolumeId, ItemId, len, focItemId) {
  480. var instance = this;
  481. $('.Plan_Vlm_row').css('background-color', '');
  482. $('#spn_Quantity').text(Volume);
  483. $("#frm_Bizgazetransact_ItemOfferSelection").find("#btn_Apply").removeAttr("style").removeClass("disabled");
  484. instance.Bizgaze_Transact_Selected_Plan = new Array();
  485. instance.Bizgaze_Transact_Selected_Plan.push({
  486. Volume: Volume, value: value, DiscountType: DiscountType, PlanVolumeId: PlanVolumeId, ItemId: ItemId, focItemId: focItemId
  487. });
  488. instance.g_Selected_Plan.push({
  489. Volume: Volume, value: value, DiscountType: DiscountType, PlanVolumeId: PlanVolumeId, ItemId: ItemId, focItemId: focItemId
  490. });
  491. }
  492. LoadOfferItems(OrganizationId, ItemId, ItemName, InvoiceApplyType, element, Type) {
  493. var instance = this;
  494. instance.Bizgaze_Transact_Selected_Plan = new Array();
  495. $('#sg_item').text(ItemName);
  496. ItemOfferSelection.Instance().GetPlanVolume(OrganizationId, ItemId, InvoiceApplyType, Type);
  497. $('#btn_Apply').click(function () {
  498. if (Type == 'Invoice') {
  499. ItemOfferSelection.Instance().Apply(element);
  500. }
  501. else if (Type == 'Order') {
  502. instance.navigationHelper.closePopUp();
  503. if (instance.Bizgaze_Transact_Selected_Plan.length > 0) {
  504. Bizgaze.Apps.Transact.Controls.OrderItems.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan);
  505. }
  506. }
  507. else if (Type == 'Estimate') {
  508. instance.navigationHelper.closePopUp();
  509. if (instance.Bizgaze_Transact_Selected_Plan.length > 0) {
  510. Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan);
  511. }
  512. }
  513. else if (Type == 'Opportunity') {
  514. instance.navigationHelper.closePopUp();
  515. if (instance.Bizgaze_Transact_Selected_Plan.length > 0) {
  516. Bizgaze.Apps.Transact.Controls.OpportunityItem.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan);
  517. }
  518. }
  519. else if (Type == 'POS_Order') {
  520. let elem = $(".variant-addeditem-" + ItemId);
  521. let html = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().getInventoryDesign(ItemId, false, 0, 0, "ApplyOffer");
  522. $(elem).find(".InventoryTypesTextboxes").html(html);
  523. Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().allItemEvents(elem);
  524. instance.navigationHelper.closePopUp();
  525. if (instance.Bizgaze_Transact_Selected_Plan.length > 0) {
  526. Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan);
  527. }
  528. }
  529. else if (Type == 'Pos') {
  530. instance.navigationHelper.closePopUp();
  531. if (instance.Bizgaze_Transact_Selected_Plan.length > 0) {
  532. Bizgaze.Apps.Transact.Controls.Pos.Instance().applyOffer(instance.Bizgaze_Transact_Selected_Plan);
  533. }
  534. }
  535. });
  536. }
  537. GetPlanVolume(OrganizationId, ItemId, InvoiceApplyType, Type) {
  538. let instance = this;
  539. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getPlanVolume(ItemId, OrganizationId, InvoiceApplyType).then(function (result) {
  540. instance.OfferIds = [];
  541. for (var i = 0; i < result.result.length; i++) {
  542. ItemOfferSelection.Instance().ShowItemOffers(result.result[i], ItemId, Type);
  543. }
  544. });
  545. }
  546. ShowItemOffers(data, ItemId, Type) {
  547. let instance = this;
  548. var value;
  549. if (data.DiscountType == 1) {
  550. value = data.PayoutValue;
  551. }
  552. else {
  553. if (data.DiscountType == 2) {
  554. value = data.PayoutPercent;
  555. }
  556. else {
  557. if (data.DiscountType == 3) {
  558. value = data.OPayoutValue;
  559. }
  560. }
  561. }
  562. var len = $('.Plan_Vlm_row').length;
  563. 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>';
  564. 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">';
  565. var html_body = '<li class="Plan_Vlm_row Plan_Vlm_row_' + data.PlanVolumeId + '">' +
  566. '<a href="javascript:;" class="text-dark">' +
  567. '<div class="" id="div_PlanVlm_' + len + '">' +
  568. '<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>' +
  569. '</div></a></li></div>';
  570. let offerIndex = instance.OfferIds.findIndex(x => x.OfferId == data.OfferId);
  571. if (offerIndex == -1) {
  572. instance.OfferIds.push({ OfferId: data.OfferId });
  573. html = html_header + html + html_body;
  574. html += '</div>';
  575. $('.Offer_Header:last').after(html);
  576. }
  577. else {
  578. html += html_body;
  579. $('#Offer_Header_' + data.OfferId).append(html);
  580. }
  581. var ss = data.PlanName;
  582. $("#li_Pln_Vlm" + len).click(function () {
  583. let Clicked_Id = $(this).attr("id");
  584. var focElement = document.getElementById("li_Pln_Vlm" + len);
  585. var focItemIdElement = focElement.querySelector(".selectedfocitem");
  586. var focItemId = "0";
  587. if (focItemIdElement != null) {
  588. focItemId = focItemIdElement.id;
  589. }
  590. let checkstatus = $(this).find("u").text();
  591. let AppliedPlanVolumeId = $(this).parents(".Card_Plan_Vlm_row").attr("id").replace("Card_Plan_Vlm_row_", "");
  592. if (checkstatus == "Apply") {
  593. $(".Card_Plan_Vlm_row").removeAttr("style");
  594. var offerItemIndex = instance.Bizgaze_Transact_Selected_Plan.findIndex(x => x.ItemId == ItemId);
  595. if (offerItemIndex != -1) {
  596. instance.Bizgaze_Transact_Selected_Plan.splice(offerItemIndex, 1);
  597. }
  598. var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId);
  599. if (offerItemIndex != -1) {
  600. instance.g_Selected_Plan.splice(sp_ItemIndex, 1);
  601. }
  602. $(".Plan_Vlm_row").find(".offers_applied").find("u").text("Apply").addClass("text-primary").removeClass("text-danger");
  603. instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, true);
  604. ItemOfferSelection.Instance().PlanSelection(data.Volume, value, data.DiscountType, data.PlanVolumeId, ItemId, len, Number(focItemId));
  605. }
  606. else {
  607. var msg = 'Do you what to remove Applied Offer';
  608. bootbox.confirm({
  609. message: msg,
  610. closeButton: false,
  611. buttons: {
  612. confirm: {
  613. label: 'Remove',
  614. className: 'btn-success'
  615. },
  616. cancel: {
  617. label: 'Cancel',
  618. className: 'btn-danger'
  619. }
  620. },
  621. callback: function (result) {
  622. if (result) {
  623. instance.UnHighlightPlan(AppliedPlanVolumeId, ItemId, Type);
  624. $("#spn_Quantity").text("");
  625. }
  626. else {
  627. $('#modal_popup_EditLineItem').modal('hide');
  628. bootbox.hideAll();
  629. return false;
  630. }
  631. }
  632. });
  633. }
  634. });
  635. if (value > 0) {
  636. $("#div_PlanVlm_" + len).find('#spn_Discount').text(value);
  637. if (data.DiscountType == 2) {
  638. $("#div_PlanVlm_" + len).find('#spn_DiscountType').text(" %");
  639. }
  640. else {
  641. if (data.DiscountType == 1)
  642. $("#div_PlanVlm_" + len).find('#spn_DiscountType').text(" Val");
  643. if (data.DiscountType == 3) {
  644. $("#div_PlanVlm_" + len).find('#spn_DiscountType').text(" Fixed Val");
  645. }
  646. }
  647. }
  648. else {
  649. $("#div_PlanVlm_" + len).find('.spn_off').addClass("hidden");
  650. }
  651. if (data.ItemVolumePayouts.length > 0) {
  652. html = '<div class="" id="div_Foc_' + len + '"></div>';
  653. $('#div_PlanVlm_' + len).after(html);
  654. for (var i = 0; i < data.ItemVolumePayouts.length; i++) {
  655. ItemOfferSelection.Instance().AddFoCItem(data.ItemVolumePayouts[i], len, Type, ItemId);
  656. }
  657. }
  658. if (Type == "POS_Order") {
  659. let CartItem_Index = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_CartItems_New.findIndex(x => x.ItemId == ItemId);
  660. if (CartItem_Index != -1) {
  661. let AppliedPlanVolumeId = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_CartItems_New[CartItem_Index].AppliedPlanVolumeId;
  662. if (AppliedPlanVolumeId != 0) {
  663. instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, false);
  664. }
  665. }
  666. }
  667. else if (Type == "Order") {
  668. let IsCart = false;
  669. if ($("#ulOrder_Cart").is(":visible")) {
  670. IsCart = true;
  671. }
  672. Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.filter(x => x.ItemId != ItemId);
  673. var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId);
  674. if (sp_ItemIndex != -1) {
  675. let selectedPlan = instance.g_Selected_Plan[sp_ItemIndex];
  676. Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.push({
  677. ItemId: selectedPlan.ItemId,
  678. OfferId: 0,
  679. PlanId: 0,
  680. PlanVolumeId: selectedPlan.PlanVolumeId,
  681. IsSelected: true
  682. });
  683. }
  684. let AppliedOffers = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.filter(x => x.ItemId == ItemId);
  685. for (var ao = 0; ao < AppliedOffers.length; ao++) {
  686. let AppliedPlanVolumeId = AppliedOffers[ao].PlanVolumeId;
  687. let IsSelected = AppliedOffers[ao].IsSelected;
  688. instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, IsSelected);
  689. }
  690. }
  691. else if (Type == "Estimate") {
  692. let IsCart = false;
  693. if ($("#ulOrder_Cart").is(":visible")) {
  694. IsCart = true;
  695. }
  696. if (!IsCart && !Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_FromContinueShopping) {
  697. Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.filter(x => x.ItemId != ItemId);
  698. var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId);
  699. if (sp_ItemIndex != -1) {
  700. let selectedPlan = instance.g_Selected_Plan[sp_ItemIndex];
  701. Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.push({
  702. ItemId: selectedPlan.ItemId,
  703. OfferId: 0,
  704. PlanId: 0,
  705. PlanVolumeId: selectedPlan.PlanVolumeId,
  706. IsSelected: true
  707. });
  708. }
  709. }
  710. let AppliedOffers = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.filter(x => x.ItemId == ItemId);
  711. for (var ao = 0; ao < AppliedOffers.length; ao++) {
  712. let AppliedPlanVolumeId = AppliedOffers[ao].PlanVolumeId;
  713. let IsSelected = AppliedOffers[ao].IsSelected;
  714. instance.HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, IsSelected);
  715. }
  716. }
  717. }
  718. HighlightAppliedPlans(AppliedPlanVolumeId, ItemId, IsSelected) {
  719. let instance = this;
  720. if (IsSelected) {
  721. $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).css("background-color", "lavender");
  722. var checkoffer = $(".Plan_Vlm_row_" + AppliedPlanVolumeId).find(".offers_applied").attr("id");
  723. $("#" + checkoffer).find("u").text("Remove").removeClass('text-sucess').addClass('text-danger');
  724. var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId);
  725. if (sp_ItemIndex != -1) {
  726. let selectedPlan = instance.g_Selected_Plan[sp_ItemIndex];
  727. instance.Bizgaze_Transact_Selected_Plan.push({
  728. Volume: selectedPlan.Volume, value: selectedPlan.value, DiscountType: selectedPlan.DiscountType, PlanVolumeId: AppliedPlanVolumeId, ItemId: ItemId, focItemId: selectedPlan.focItemId
  729. });
  730. }
  731. }
  732. else {
  733. $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).css("background-color", "lightgoldenrodyellow");
  734. $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).find("u").text("Apply").addClass('text-sucess').removeClass('text-danger');
  735. }
  736. $("#frm_Bizgazetransact_ItemOfferSelection").find("#btn_Apply").removeAttr("style").removeClass("disabled");
  737. }
  738. UnHighlightPlan(AppliedPlanVolumeId, ItemId, Type) {
  739. let instance = this;
  740. $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).find("u").text("Apply").addClass('text-sucess').removeClass('text-danger');
  741. $(".Card_Plan_Vlm_row_" + AppliedPlanVolumeId).removeAttr("style");
  742. var offerItemIndex = instance.Bizgaze_Transact_Selected_Plan.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId);
  743. if (offerItemIndex != -1) {
  744. instance.Bizgaze_Transact_Selected_Plan.splice(offerItemIndex, 1);
  745. }
  746. var sp_ItemIndex = instance.g_Selected_Plan.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId);
  747. if (offerItemIndex != -1) {
  748. instance.g_Selected_Plan.splice(sp_ItemIndex, 1);
  749. }
  750. if (Type == "Order") {
  751. var appliedoffers_ItemIndex = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId);
  752. if (appliedoffers_ItemIndex != -1) {
  753. Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_AppliedOffers.splice(appliedoffers_ItemIndex, 1);
  754. }
  755. }
  756. if (Type == "Estimate") {
  757. var appliedoffers_ItemIndex = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.findIndex(x => x.ItemId == ItemId && x.PlanVolumeId == AppliedPlanVolumeId);
  758. if (appliedoffers_ItemIndex != -1) {
  759. Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_AppliedOffers.splice(appliedoffers_ItemIndex, 1);
  760. }
  761. }
  762. }
  763. AddFoCItem(FocItem, len, Type, RefItemId) {
  764. 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>' +
  765. '</div>';
  766. $('#div_Foc_' + len).before(html);
  767. var seen = '';
  768. $('.plan_Name').each(function () {
  769. var see = $(this).text();
  770. if (seen.match(see)) {
  771. $(this).remove();
  772. }
  773. else {
  774. seen = seen + $(this).text();
  775. }
  776. });
  777. if (Type == "Order") {
  778. var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds == RefItemId);
  779. if (!FocItem.IsFoC) {
  780. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
  781. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true");
  782. }
  783. else if (FocItem.IsFoC && ValidFocItemIndex != -1) {
  784. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
  785. }
  786. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () {
  787. var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked");
  788. var FocItemIndex = Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.toString().indexOf(RefItemId) != -1);
  789. if (Checked) {
  790. if (FocItemIndex == -1) {
  791. Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.push({ ItemId: FocItem.ItemId, RefItemIds: RefItemId });
  792. }
  793. }
  794. else {
  795. if (FocItemIndex != -1) {
  796. Bizgaze.Apps.Transact.Controls.OrderItems.Instance().g_ValidFocItems.splice(FocItemIndex, 1);
  797. }
  798. }
  799. });
  800. }
  801. if (Type == "Estimate") {
  802. var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds == RefItemId);
  803. if (!FocItem.IsFoC) {
  804. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
  805. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true");
  806. }
  807. else if (FocItem.IsFoC && ValidFocItemIndex != -1) {
  808. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
  809. }
  810. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () {
  811. var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked");
  812. var FocItemIndex = Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.toString().indexOf(RefItemId) != -1);
  813. if (Checked) {
  814. if (FocItemIndex == -1) {
  815. Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.push({ ItemId: FocItem.ItemId, RefItemIds: RefItemId });
  816. }
  817. }
  818. else {
  819. if (FocItemIndex != -1) {
  820. Bizgaze.Apps.Transact.Controls.EstimateItems.Instance().g_ValidFocItems.splice(FocItemIndex, 1);
  821. }
  822. }
  823. });
  824. }
  825. if (Type == "POS_Order") {
  826. var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.indexOf(RefItemId) != -1);
  827. if (!FocItem.IsFoC) {
  828. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
  829. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true");
  830. }
  831. else if (FocItem.IsFoC && ValidFocItemIndex != -1) {
  832. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
  833. }
  834. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () {
  835. var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked");
  836. var FocItemIndex = Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemIds.indexOf(RefItemId) != -1);
  837. if (Checked) {
  838. if (FocItemIndex == -1) {
  839. Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.push({ ItemId: FocItem.ItemId, RefItemIds: RefItemId });
  840. }
  841. }
  842. else {
  843. if (FocItemIndex != -1) {
  844. Bizgaze.Apps.Transact.Controls.POSCartItems.Instance().g_ValidFocItems.splice(FocItemIndex, 1);
  845. }
  846. }
  847. });
  848. }
  849. if (Type == "Pos") {
  850. var ValidFocItemIndex = Bizgaze.Apps.Transact.Controls.Pos.Instance().offerItemsArray.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemId == RefItemId);
  851. if (!FocItem.IsFoC) {
  852. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
  853. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).attr("disabled", "true").addClass("opacity-30");
  854. }
  855. else if (FocItem.IsFoC && ValidFocItemIndex != -1) {
  856. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked", true);
  857. }
  858. $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).change(function () {
  859. var Checked = $("#IsApplyOffer_" + FocItem.ItemVolumePayoutId).prop("checked");
  860. var FocItemIndex = Bizgaze.Apps.Transact.Controls.Pos.Instance().offerItemsArray.findIndex(x => x.ItemId == FocItem.ItemId && x.RefItemId == RefItemId);
  861. if (Checked) {
  862. if (FocItemIndex == -1) {
  863. Bizgaze.Apps.Transact.Controls.Pos.Instance().offerItemsArray.push({ ItemId: FocItem.ItemId, RefItemId: RefItemId });
  864. }
  865. }
  866. });
  867. }
  868. }
  869. Apply(element) {
  870. let instance = this;
  871. instance.navigationHelper.closePopUp();
  872. ItemOfferSelection.Instance().ApplyOffer(instance.Bizgaze_Transact_Selected_Plan, element);
  873. }
  874. AddSpliItem(element) {
  875. var array = {
  876. orderItemId: 0,
  877. invoiceItemId: 0,
  878. itemId: element.find('.selectedItemId').val(),
  879. packSize: 0,
  880. packCount: 0,
  881. packs: 0,
  882. quantity: 0,
  883. availPacks: 0,
  884. availQty: 0,
  885. Description: "",
  886. isTaxInclusive: $("#hfIsTaxInclusive").val(),
  887. addlDiscountPercent: 0,
  888. addlDiscountValue: 0,
  889. creditNote: 0,
  890. priceListId: element.find('.hf_PriceList').val(),
  891. invoiceallocations: null,
  892. exciseInvoiceItem: null,
  893. walletId: 0,
  894. Adjustment: 0,
  895. IsFoc: 0,
  896. TariffNo: "",
  897. exciseAmount: 0,
  898. discountName: "",
  899. discountId: 0,
  900. description: "",
  901. RefNo: "",
  902. DiscountGroupId: 0,
  903. DiscountGroupName: '',
  904. RefInvoiceItemId: 0,
  905. taxAdjustment: element.find('.hfItemTaxAdjsutmentVal').val(),
  906. assesableAdjustment: element.find('.hfItemAssesableAdjustmentVal').val(),
  907. inventoryTypeId: 0,
  908. dcItemId: element.find('.dcItemId').val(),
  909. ExchangeItem: element.find('.IsExchangeItem').val(),
  910. unitPrice: element.find('.prodPrice').val(),
  911. taxGroupId: element.find(".hfProdTax").val(),
  912. BatchId: 0,
  913. MrpId: 0,
  914. SerialId: 0,
  915. Name: '',
  916. maxQty: 0,
  917. accountId: element.find(".hf_Account").val(),
  918. accountName: element.find(".txt_AccountName").val(),
  919. taxGroupName: element.find(".txtProdTax").val(),
  920. };
  921. return array;
  922. }
  923. AddItemRowToSplitArray(Item, element, Quantity) {
  924. var DcType = 2;
  925. var BranchId = $(".txtAutoComplete_shiptoaddressid").val();
  926. if ($('.hdn_invoicetypeid').val() == '1' || $('.hdn_invoicetypeid').val() == '4' || $('.hdn_invoicetypeid').val() == '5') {
  927. BranchId = $(".txtAutoComplete_shipfromaddressid").val();
  928. }
  929. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "5") {
  930. DcType = 1;
  931. }
  932. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemSetting(Item, BranchId, DcType).then(function (result) {
  933. var EnableMrp = result.result.EnableMRP;
  934. var EnableBatch = result.result.EnableBatchNo;
  935. var Info = [];
  936. if (EnableMrp == true) {
  937. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getMrps(element.find(".selectedItemId").val(), DcType, BranchId).then(function (res) {
  938. Info = res.result;
  939. });
  940. }
  941. if (EnableBatch == true) {
  942. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getBatches(element.find(".selectedItemId").val(), DcType, BranchId).then(function (res) {
  943. Info = res.result;
  944. });
  945. }
  946. if (Info.length > 0) {
  947. var TotalQuantity = 0;
  948. var TotalDisc = 0;
  949. var TotalAmount = 0;
  950. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "5") {
  951. var itemQty = Quantity;
  952. for (var x = 0; x < Info.length; x++) {
  953. if (itemQty > 0) {
  954. var itemrow = ItemOfferSelection.Instance().AddSpliItem(element);
  955. let Qty = 0;
  956. if (EnableMrp == true) {
  957. itemrow.MrpId = Info[x].MrpId;
  958. itemrow.Name = Info[x].Mrp + ' ( ' + Info[x].MrpQuantity + ' ) ';
  959. Qty = Info[x].MrpQuantity;
  960. }
  961. else if (EnableBatch == true) {
  962. itemrow.BatchId = Info[x].BatchId;
  963. itemrow.Name = Info[0].BatchNo;
  964. Qty = Info[0].BatchQuantity;
  965. }
  966. if (Qty > itemQty) {
  967. itemrow.quantity = itemQty;
  968. itemQty = itemQty - Info[x].Quantity;
  969. }
  970. else {
  971. itemrow.quantity = Qty;
  972. itemQty = itemQty - Qty;
  973. }
  974. Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.push(itemrow);
  975. TotalQuantity += Number(itemrow.quantity);
  976. var discount = 0;
  977. var qyt = Number(itemrow.quantity);
  978. var price = Number(itemrow.unitPrice);
  979. var excamt = Number(itemrow.exciseAmount);
  980. var assesableAdjustment = Number(itemrow.assesableAdjustment);
  981. var ItemAdjustment = Number(itemrow.Adjustment);
  982. var discountAmount = Number(itemrow.addlDiscountValue);
  983. var discountPercent = Number(itemrow.addlDiscountPercent);
  984. discount = (((qyt * price) + assesableAdjustment + ItemAdjustment - excamt) * Number(discountPercent) / 100) + (Number(qyt) * Number(discountAmount));
  985. discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3));
  986. TotalDisc += discount;
  987. var rowtotal = Number((qyt * price) + excamt + ItemAdjustment + assesableAdjustment);
  988. var RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3);
  989. TotalAmount += RowTotal;
  990. }
  991. }
  992. }
  993. else {
  994. var itemrow = ItemOfferSelection.Instance().AddSpliItem(element);
  995. if (EnableMrp == true) {
  996. itemrow.MrpId = Info[0].MrpId;
  997. itemrow.Name = Info[0].Mrp + ' ( ' + Info[0].Quantity + ' ) ';
  998. }
  999. else if (EnableBatch == true) {
  1000. itemrow.BatchId = Info[0].BatchId;
  1001. itemrow.Name = Info[0].BatchNo;
  1002. }
  1003. itemrow.quantity = Quantity;
  1004. Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().SplitedInvoiceItemList.push(itemrow);
  1005. TotalQuantity += Number(itemrow.quantity);
  1006. var discount = 0;
  1007. var qyt = Number(itemrow.quantity);
  1008. var price = Number(itemrow.unitPrice);
  1009. var excamt = Number(itemrow.exciseAmount);
  1010. var assesableAdjustment = Number(itemrow.assesableAdjustment);
  1011. var ItemAdjustment = Number(itemrow.Adjustment);
  1012. var discountAmount = Number(itemrow.addlDiscountValue);
  1013. var discountPercent = Number(itemrow.addlDiscountPercent);
  1014. discount = (((qyt * price) + assesableAdjustment + ItemAdjustment - excamt) * Number(discountPercent) / 100) + (Number(qyt) * Number(discountAmount));
  1015. discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3));
  1016. TotalDisc += discount;
  1017. var rowtotal = Number((qyt * price) + excamt + ItemAdjustment + assesableAdjustment);
  1018. var RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3);
  1019. TotalAmount += RowTotal;
  1020. }
  1021. if (EnableMrp == true)
  1022. element.find('.spn_InvoiceItem').text("View MRP");
  1023. else
  1024. element.find('.spn_InvoiceItem').text("View Batch");
  1025. element.find('.prodQuantity').val();
  1026. element.find('.prodQuantity').val(TotalQuantity);
  1027. element.find('#inv_txtdiscount').val();
  1028. element.find('#inv_txtdiscount').val(TotalDisc);
  1029. if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "6") {
  1030. element.find(".txtRowTotalwithAdjustment").val();
  1031. element.find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(TotalAmount, 3));
  1032. }
  1033. else {
  1034. element.find('.prodTotalPrice').text('');
  1035. element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(TotalAmount, 3));
  1036. }
  1037. Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(element.find(".selectedItemId").val(), element.find('.prodQuantity').val(), element);
  1038. }
  1039. });
  1040. }
  1041. ApplyOffer(Item, element) {
  1042. if (element.hasClass('SplitItem')) {
  1043. var Qty = Number(element.find(".prodQuantity").val());
  1044. if (Qty == 0) {
  1045. ItemOfferSelection.Instance().AddItemRowToSplitArray(Item, element, Item[0].Volume);
  1046. Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_total();
  1047. }
  1048. else if (Qty < Item[0].Volume) {
  1049. var ItemQty = Item[0].Volume - Qty;
  1050. ItemOfferSelection.Instance().AddItemRowToSplitArray(Item, element, ItemQty);
  1051. Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_row_total(element, true);
  1052. }
  1053. else {
  1054. Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(element.find(".selectedItemId").val(), Qty, element);
  1055. Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_row_total(element, true);
  1056. }
  1057. }
  1058. else {
  1059. element.find(".prodQuantity").val(Item[0].Volume);
  1060. Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().GetPlanItems(element.find(".selectedItemId").val(), element.find(".prodQuantity").val(), element);
  1061. Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().update_row_total(element, true);
  1062. }
  1063. }
  1064. static Instance() {
  1065. if (this.instance === undefined) {
  1066. this.instance = new Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection();
  1067. }
  1068. return this.instance;
  1069. }
  1070. }
  1071. Invoices.ItemOfferSelection = ItemOfferSelection;
  1072. })(Invoices = Components.Invoices || (Components.Invoices = {}));
  1073. })(Components = Transact.Components || (Transact.Components = {}));
  1074. })(Transact = Apps.Transact || (Apps.Transact = {}));
  1075. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  1076. })(Bizgaze || (Bizgaze = {}));
  1077. var Bizgaze;
  1078. (function (Bizgaze) {
  1079. let Apps;
  1080. (function (Apps) {
  1081. let Transact;
  1082. (function (Transact) {
  1083. let Controls;
  1084. (function (Controls) {
  1085. class InvoiceItem extends Unibase.Platform.Core.BaseComponent {
  1086. constructor() {
  1087. super(...arguments);
  1088. this.rowIndex = 0;
  1089. this.itemIds = new Array();
  1090. this.dcItemIds = new Array();
  1091. this.SplitedInvoiceItemList = new Array();
  1092. this.deleted_invoiceItems = new Array();
  1093. this.invItemTaxAdjustmentList = new Array();
  1094. this.container = "";
  1095. this.AutoDc = false;
  1096. this.OrderSettingId = 0;
  1097. this.orderid = 0;
  1098. this.dcid = 0;
  1099. this.ClaimId = 0;
  1100. this.TurnOver = 0;
  1101. this.TaxRate = 0;
  1102. this.ContactTcsEnable = false;
  1103. this.EnableTenantTcs = false;
  1104. this.PanAvailable = false;
  1105. this.IswalkinCustomer = false;
  1106. this.ManageInvoice = 2;
  1107. this.ManageInvoiceTax = 2;
  1108. this.UOMs = [];
  1109. this.ChangedUOM = false;
  1110. this.isOfferChargeApplied = false;
  1111. }
  1112. init(formpropertyid, prop, callback) {
  1113. var instance = InvoiceItem.Instance();
  1114. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/core/helpers/numberhelper/numberhelper.js", function () {
  1115. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () {
  1116. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/paymentterms/paymenttermmanager.js", function () {
  1117. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/offers/offermanager.js", function () {
  1118. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/compact/components/details/details.js", function () {
  1119. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/forms/components/formviewer/formviewer.js", function () {
  1120. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("libs/parsley/parsley.min.js", function () {
  1121. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
  1122. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  1123. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  1124. });
  1125. });
  1126. });
  1127. });
  1128. });
  1129. });
  1130. });
  1131. });
  1132. }
  1133. loadControl(containerid, prop) {
  1134. let instance = this;
  1135. 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>';
  1136. $("#" + containerid).html(html);
  1137. $('.advanced-opitions').on('click', function () {
  1138. $('#change_taxgroup').val(null).trigger('change');
  1139. $('.advchange_taxgroup').toggleClass('hidden-element');
  1140. $('.advchange_taxgroup').find('.select2-selection__placeholder span').text('Select Tax Group');
  1141. });
  1142. InvoiceItem.instance.container = containerid;
  1143. InvoiceItem.Instance().loadChangeTaxGroupAutoComplete();
  1144. }
  1145. invoiceinit() {
  1146. if (InvoiceItem.Instance().orderid != 0) {
  1147. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  1148. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorderbranchsettings(InvoiceItem.Instance().orderid).then(function (response) {
  1149. if (response.result != null) {
  1150. if (response.result.SettingValue == "Invoice First") {
  1151. InvoiceItem.Instance().OrderSettingId = 2;
  1152. }
  1153. else if (response.result.SettingValue == "DC First" || response.result.SettingValue == "GRN First") {
  1154. InvoiceItem.Instance().OrderSettingId = 1;
  1155. }
  1156. }
  1157. });
  1158. }
  1159. $(".dropdown_istaxinclusive option[value='false']").attr('selected', 'true');
  1160. $(".dropdown_paymentmethodid option[value='0']").attr('selected', 'true');
  1161. $(".nettotal").remove();
  1162. var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  1163. $("#" + VisibleContainerId).find(".btn_Save_Form").addClass("hidden");
  1164. var nettotal = '<strong class="nettotal mt-5 mr-5">0.00</strong>';
  1165. if ($('.Title').siblings('.btn-group').length > 0)
  1166. $('.Title').siblings('.btn-group').prepend(nettotal);
  1167. else
  1168. $('.Title').after('<strong class="nettotal mt-5 mr-5 ml-auto">0.00</strong>');
  1169. $('.txtAutoComplete_paymenttermid').change(function () {
  1170. InvoiceItem.Instance().LoadDueDays();
  1171. });
  1172. $('.date_journaldate').blur(function () {
  1173. InvoiceItem.Instance().LoadDueDays();
  1174. if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") && $("#chk_tcsapplied").val() != undefined)
  1175. InvoiceItem.Instance().GetCustomerTurnOver();
  1176. });
  1177. $('.date_journaldate').change(function () {
  1178. var invdate = $('.date_journaldate').val().toString().split('/');
  1179. let todaydate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(), "").split('/');
  1180. var Invoicedate = new Date(Number(invdate[2]), Number(invdate[1]) - 1, Number(invdate[0]));
  1181. var CurrentDate = new Date(Number(todaydate[2]), Number(todaydate[1]) - 1, Number(todaydate[0]));
  1182. if (Invoicedate > CurrentDate) {
  1183. bootbox.confirm("Are You Sure,You want to Continue with Future Invoice", function (result) {
  1184. if (result) {
  1185. InvoiceItem.Instance().GetAvailableWallets(Number($(".hdn_invoiceid").val()));
  1186. }
  1187. else {
  1188. var f = new Date();
  1189. $('.date_journaldate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, ""));
  1190. let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, "");
  1191. var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
  1192. $('.hfdate_journaldate').val(tdate);
  1193. InvoiceItem.Instance().GetAvailableWallets(Number($(".hdn_invoiceid").val()));
  1194. }
  1195. });
  1196. }
  1197. else {
  1198. InvoiceItem.Instance().GetAvailableWallets(Number($(".hdn_invoiceid").val()));
  1199. }
  1200. InvoiceItem.Instance().GetDiscounts();
  1201. });
  1202. $('.date_refdate').blur(function () {
  1203. let refdate = $(".date_refdate").val();
  1204. if (refdate == "" || refdate == null) {
  1205. var f = new Date();
  1206. $('.date_refdate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, ""));
  1207. let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(f, "");
  1208. var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
  1209. $('.hfdate_refdate').val(tdate);
  1210. $(".divCustomProperties_refdate").children().addClass("floating-label-form-group-with-value");
  1211. }
  1212. });
  1213. $(".section_Ebs").addClass("hidden");
  1214. $(".section_Details").addClass('hidden');
  1215. $(".section_ItemDetails").addClass('hidden');
  1216. $(".section_Ebs").addClass('hidden');
  1217. $(".section_InvoiceAmount").addClass('hidden');
  1218. $(".section_Description").addClass('hidden');
  1219. $(".section_BillingAndShippingDetails").addClass('hidden');
  1220. $(".section_AdvancedOptions").addClass("hidden");
  1221. $(".section_Description").addClass("hidden");
  1222. $(".section_Wallets").addClass("hidden");
  1223. $(".section_TCS").addClass("hidden");
  1224. $("#div_tcstaxrate").addClass("hidden");
  1225. $(".div_tcsadjustment").addClass("hidden");
  1226. $("#div_tcsamount").addClass("hidden");
  1227. $(".number_tcsamount").prop("disabled", true);
  1228. $(".number_tdsamount").prop("disabled", true);
  1229. $(".number_tdstaxrate").prop("disabled", true);
  1230. $('#chk_excludefromcampaign').prop('checked', false);
  1231. $(".txt_gstno").prop("disabled", true);
  1232. $(".section_InvoiceAmount .card-header").first().text('Amount');
  1233. $(".hrefSection_MoreOptions").click(function () {
  1234. if ($(".hrefSection_MoreOptions").text() == 'Less Options') {
  1235. $(".hrefSection_MoreOptions").text('More Options');
  1236. $(".section_AdvancedOptions").addClass("hidden");
  1237. }
  1238. else if ($(".hrefSection_MoreOptions").text() == 'More Options') {
  1239. $(".hrefSection_MoreOptions").text('Less Options');
  1240. $(".section_AdvancedOptions").removeClass("hidden");
  1241. }
  1242. });
  1243. if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser().settings == null) {
  1244. $(".txtAutoComplete_orgcontactid").prop("disabled", true);
  1245. MessageHelper.Instance().showError("Please Configure Default Branch", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  1246. return false;
  1247. }
  1248. else if (Unibase.Platform.Membership.Infos.Identity.getSetting("companyid") == null || Unibase.Platform.Membership.Infos.Identity.getSetting("companyid") == undefined) {
  1249. $(".txtAutoComplete_orgcontactid").prop("disabled", true);
  1250. MessageHelper.Instance().showError("Please Configure Default Branch", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  1251. return false;
  1252. }
  1253. else {
  1254. var companyId = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("companyid"));
  1255. if ($(".hdn_invoicetypeid").val() != "6" && $(".hdn_invoicetypeid").val() != "7") {
  1256. var Parameters = [{ "ColumnName": "companyid", "Value": companyId }];
  1257. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_orgcontactid"), Parameters);
  1258. }
  1259. }
  1260. if ($(".hdn_invoiceid").val() == 0 && InvoiceItem.Instance().orderid == 0 && InvoiceItem.Instance().dcid == 0) {
  1261. $(".txtAutoComplete_orgcontactid").change(function () {
  1262. var orgid = Number($(".hfAutoCompleteId_orgcontactid").val());
  1263. if (orgid > 0) {
  1264. if ($(".section_Details").hasClass('hidden')) {
  1265. $(".section_Details").removeClass('hidden');
  1266. }
  1267. if ($(".section_ItemDetails").hasClass('hidden')) {
  1268. $(".section_ItemDetails").removeClass('hidden');
  1269. }
  1270. if ($(".section_InvoiceAmount").hasClass('hidden')) {
  1271. $(".section_InvoiceAmount").removeClass('hidden');
  1272. }
  1273. if ($(".section_Description").hasClass('hidden')) {
  1274. $(".section_Description").removeClass('hidden');
  1275. }
  1276. if ($(".section_BillingAndShippingDetails").hasClass('hidden')) {
  1277. $(".section_BillingAndShippingDetails").removeClass('hidden');
  1278. }
  1279. if ($(".section_Wallets").hasClass('hidden')) {
  1280. $(".section_Wallets").removeClass("hidden");
  1281. }
  1282. if ($(".section_TCS").hasClass('hidden')) {
  1283. $(".section_TCS").removeClass("hidden");
  1284. }
  1285. var organiztionid = $(".hfAutoCompleteId_orgcontactid").val();
  1286. if (organiztionid != 0 && organiztionid != undefined && organiztionid != -1) {
  1287. InvoiceItem.Instance().LoadContactDetails();
  1288. }
  1289. $("#btn_Save").removeClass('hidden');
  1290. var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  1291. $("#" + VisibleContainerId).find(".btn_Save_Form").removeClass("hidden");
  1292. }
  1293. });
  1294. }
  1295. $('.dropdown_istaxinclusive').change(function () {
  1296. var invItems = InvoiceItem.Instance().getInvoiceItems();
  1297. InvoiceItem.Instance().update_total();
  1298. InvoiceItem.Instance().TotalAdjustment();
  1299. });
  1300. if (Unibase.Platform.Membership.Infos.Identity.getCurrentUser().isAdmin == true) {
  1301. InvoiceItem.Instance().ManageInvoice = 2;
  1302. InvoiceItem.Instance().ManageInvoiceTax = 2;
  1303. }
  1304. else {
  1305. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().GetInvoicePermissions(Number($(".hdn_invoicetypeid").val())).then(function (response) {
  1306. if (response.result.length > 0) {
  1307. for (var i = 0; i < response.result.length; i++) {
  1308. if (response.result[i].SettingName == Unibase.Platform.Apps.Enums.SettingType.Manage.toString()) {
  1309. InvoiceItem.Instance().ManageInvoice = response.result[i].SettingValue;
  1310. InvoiceItem.Instance().ManageInvoiceTax = response.result[i].SettingValue;
  1311. }
  1312. }
  1313. }
  1314. });
  1315. }
  1316. if ($(".WalletItems").hasClass('show')) {
  1317. $(".WalletItems").removeClass('show');
  1318. }
  1319. let invoiceid = $(".hdn_invoiceid").val();
  1320. if (invoiceid == "0") {
  1321. if (InvoiceItem.Instance().orderid != 0 || InvoiceItem.Instance().dcid != 0)
  1322. InvoiceItem.Instance().getDcDetails();
  1323. $('#txt_Adjustment').keypress(function (event) {
  1324. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8) || (event.which == 45)) {
  1325. }
  1326. else {
  1327. event.preventDefault();
  1328. }
  1329. }).on('paste', function (event) {
  1330. event.preventDefault();
  1331. });
  1332. }
  1333. else {
  1334. InvoiceItem.Instance().bindEditInvoiceDetails(invoiceid);
  1335. }
  1336. $('#change_taxgroup').change(function () {
  1337. if ($('#change_taxgroup option:selected').val() != undefined && $('#change_taxgroup option:selected').val() != 0) {
  1338. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  1339. InvoiceItem.Instance().SplitedInvoiceItemList[i].taxGroupId = Number($('#change_taxgroup option:selected').val());
  1340. Controls.Invoices.SplitItem.Instance().update_TaxPercentage($('#change_taxgroup option:selected').val());
  1341. }
  1342. $(".InvoiceItems").find(".item-row").each(function () {
  1343. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  1344. var TaxGroupId = Number($('#change_taxgroup option:selected').val());
  1345. var txtTaxGroup = $(this).find(".prodTax");
  1346. var hfProdTax = $(this).find(".hfProdTax");
  1347. hfProdTax.val(TaxGroupId);
  1348. txtTaxGroup.empty();
  1349. txtTaxGroup.append(new Option($('#change_taxgroup option:selected').text(), TaxGroupId.toString(), true));
  1350. if (hfProdTax.val() != '')
  1351. InvoiceItem.Instance().update_tax($(this), hfProdTax.val());
  1352. }
  1353. });
  1354. }
  1355. });
  1356. }
  1357. addNetDiscountRow() {
  1358. InvoiceItem.Instance().adddiscountrow(null, "", "", true);
  1359. }
  1360. getDcDetails() {
  1361. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () {
  1362. var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  1363. $("#" + VisibleContainerId).find(".btn_Save_Form").removeClass("hidden");
  1364. $("#btn_Save").removeClass('hidden');
  1365. InvoiceItem.Instance().AutoDc = false;
  1366. let url = "";
  1367. if (InvoiceItem.Instance().dcid != 0) {
  1368. url = 'apis/v4/bizgaze/transact/dcs/getdc/dcid/' + InvoiceItem.Instance().dcid;
  1369. }
  1370. else {
  1371. url = "apis/v4/bizgaze/transact/orders/getorderbyorderid/id/" + InvoiceItem.Instance().orderid;
  1372. }
  1373. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getOrderDcDetails(url).then(function (response) {
  1374. if (response.result != null) {
  1375. if ($(".hdn_invoicetypeid").val() == "1")
  1376. $("#div_FormName").text("Create Sales Invoice");
  1377. else if ($(".hdn_invoicetypeid").val() == "2")
  1378. $("#div_FormName").text("Create Purchase Invoice");
  1379. if ($(".section_Details").hasClass('hidden')) {
  1380. $(".section_Details").removeClass('hidden');
  1381. }
  1382. if ($(".section_ItemDetails").hasClass('hidden')) {
  1383. $(".section_ItemDetails").removeClass('hidden');
  1384. }
  1385. if ($(".section_Ebs").hasClass('hidden')) {
  1386. $(".section_Ebs").removeClass('hidden');
  1387. }
  1388. if ($(".section_InvoiceAmount").hasClass('hidden')) {
  1389. $(".section_InvoiceAmount").removeClass('hidden');
  1390. }
  1391. if ($(".section_Description").hasClass('hidden')) {
  1392. $(".section_Description").removeClass('hidden');
  1393. }
  1394. if ($(".section_BillingAndShippingDetails ").hasClass('hidden')) {
  1395. $(".section_BillingAndShippingDetails ").removeClass('hidden');
  1396. }
  1397. if ($(".section_Wallets").hasClass('hidden')) {
  1398. $(".section_Wallets").removeClass("hidden");
  1399. }
  1400. if ($(".section_TCS").hasClass('hidden')) {
  1401. $(".section_TCS").removeClass("hidden");
  1402. }
  1403. let data = response.result;
  1404. $(".txtAutoComplete_orgcontactid").empty();
  1405. if (data.OrgContactId == 0) {
  1406. InvoiceItem.Instance().IswalkinCustomer = true;
  1407. $(".hfAutoCompleteId_orgcontactid").val(data.OrganizationId);
  1408. var selectedCompany = new Option(data.OrganizationName, data.OrganizationId, true);
  1409. $(".txtAutoComplete_orgcontactid").append(selectedCompany);
  1410. }
  1411. else {
  1412. InvoiceItem.Instance().IswalkinCustomer = false;
  1413. $(".hfAutoCompleteId_orgcontactid").val(data.OrgContactId);
  1414. var selectedCompany = new Option(data.OrganizationName + " - " + data.OrgContactName, data.OrgContactId, true);
  1415. $(".txtAutoComplete_orgcontactid").append(selectedCompany);
  1416. }
  1417. if (data.CurrencyId != 0) {
  1418. $(".hdn_currencyid").val(data.CurrencyId);
  1419. $(".hdn_conversionrate").val(data.ConversionRate);
  1420. }
  1421. if (data.OrganizationId != 0) {
  1422. $(".hdn_organizationid").val(data.OrganizationId);
  1423. $("#hfInv_OrganizationName").val(data.OrganizationName);
  1424. }
  1425. else {
  1426. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorgcontact(data.OrgContactId).then(function (response) {
  1427. var data = response.result;
  1428. if (response.result != null && data.OrganizationId != 0) {
  1429. $(".hdn_organizationid").val(response.result.OrganizationId);
  1430. $("#hfInv_OrganizationName").val(data.OrganizationName);
  1431. }
  1432. });
  1433. }
  1434. $(".txt_gstno").val(response.result.GSTInNo);
  1435. $(".txtAutoComplete_billfromaddressid").append(new Option(data.BillFromAddressName, data.BillFromAddressId, true));
  1436. $(".txtAutoComplete_shipfromaddressid").append(new Option(data.ShipFromAddressName, data.ShipFromAddressId, true));
  1437. if (InvoiceItem.Instance().orderid != 0 && InvoiceItem.Instance().dcid == 0) {
  1438. $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillingAddressName, data.BillingAddressId, true));
  1439. $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShippingAddressName, data.ShippingAddressId, true));
  1440. }
  1441. else {
  1442. $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillToAddressName, data.BillToAddressId, true));
  1443. $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShipToAddressName, data.ShipToAddressId, true));
  1444. }
  1445. if ((InvoiceItem.Instance().orderid != 0 || InvoiceItem.Instance().dcid != 0) && InvoiceItem.Instance().AutoDc == false) {
  1446. $('.txtAutoComplete_billfromaddressid').prop('disabled', true);
  1447. $('.txtAutoComplete_shipfromaddressid').prop('disabled', true);
  1448. $('.txtAutoComplete_billtoaddressid').prop('disabled', true);
  1449. $('.txtAutoComplete_shiptoaddressid').prop('disabled', true);
  1450. }
  1451. $(".txtAutoComplete_orgcontactid").prop('disabled', true);
  1452. $('.hfAutoCompleteId_lobid').val(data.LobId);
  1453. $('.txtAutoComplete_lobid').empty();
  1454. $('.txtAutoComplete_lobid').append(new Option(data.LobName, data.LobId, true));
  1455. $('.txtAutoComplete_lobid').prop('disabled', true);
  1456. if (data.RefNo != "" && data.RefNo != null) {
  1457. $(".txt_refno").val(data.RefNo);
  1458. $(".div_refno").addClass("floating-label-form-group-with-value");
  1459. }
  1460. else {
  1461. $(".txt_refno").val("");
  1462. $(".div_refno").removeClass("floating-label-form-group-with-value");
  1463. }
  1464. $('.txtAutoComplete_salespersonid').append(new Option(data.SalesPersonName, data.SalesPersonId, true));
  1465. $('.hfAutoCompleteId_salespersonid').val(data.SalesPersonId);
  1466. if (InvoiceItem.Instance().orderid != 0 && InvoiceItem.Instance().orderid != undefined) {
  1467. if (data.PaymentTermId != 0) {
  1468. $('.hfAutoCompleteId_paymenttermid').val(data.PaymentTermId);
  1469. $('.txtAutoComplete_paymenttermid').append(new Option(data.PaymentTermName, data.PaymentTermId, true));
  1470. InvoiceItem.Instance().LoadDueDays();
  1471. $(".txtAutoComplete_paymenttermid").prop('disabled', true);
  1472. }
  1473. $(".dropdown_paymentmethodid").val(data.PaymentMethodId);
  1474. $(".dropdown_paymentmethodid").prop('disabled', true);
  1475. if (data.BranchId != 0)
  1476. $(".hdn_branchid").val(data.BranchId);
  1477. $(".dropdown_istaxinclusive").val(data.IsTaxInclusive.toString());
  1478. $(".dropdown_istaxinclusive").prop('disabled', true);
  1479. }
  1480. if (data.Description != null && data.Description != "")
  1481. $(".divCustomProperties_systemnotes").find("textarea").val(data.Description);
  1482. else
  1483. $(".divCustomProperties_systemnotes").find("textarea").val("");
  1484. $("#txt_AdjustmentAccountName").empty();
  1485. $("#hf_AdjustmentAccountId").val("0");
  1486. var Addr = $(".txtAutoComplete_billtoaddressid option:selected").val();
  1487. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6")
  1488. Addr = $(".txtAutoComplete_billfromaddressid option:selected").val();
  1489. InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Addr);
  1490. InvoiceItem.Instance().bindAdjustmentAccount(data.LobId, Addr);
  1491. InvoiceItem.Instance().getGSTNo();
  1492. var Address = $(".txtAutoComplete_billtoaddressid option:selected").val();
  1493. if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7")
  1494. Address = $(".txtAutoComplete_billfromaddressid option:selected").val();
  1495. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
  1496. Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressByContactId(Address).then(function (response) {
  1497. if (response.result != null) {
  1498. if (response.result.GSTNO != "" && response.result.GSTNO != null)
  1499. $(".txt_gstno").val(response.result.GSTNO);
  1500. }
  1501. });
  1502. });
  1503. if ((data.OrderId == 0 || data.OrderId == undefined) && (InvoiceItem.Instance().dcid != 0 && InvoiceItem.Instance().dcid != undefined)) {
  1504. InvoiceItem.Instance().bindDefaultPaymentTerm(data.OrganizationId, data.LobId);
  1505. }
  1506. 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) {
  1507. $("#div_tcstaxrate").addClass("hidden");
  1508. $(".div_tcsadjustment").addClass("hidden");
  1509. $("#div_tcsamount").addClass("hidden");
  1510. $(".number_tcsamount").prop("disabled", true);
  1511. InvoiceItem.Instance().GetCustomerTurnOver();
  1512. }
  1513. InvoiceItem.Instance().GetAvailableWallets(0);
  1514. InvoiceItem.Instance().loadOrderPendingItems();
  1515. InvoiceItem.Instance().IsCustomerIndustrial(data.LobId, data.OrganizationId);
  1516. }
  1517. });
  1518. });
  1519. }
  1520. bindSeries(lobid, branchid) {
  1521. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getSeries($("#hf_FormInstalledAppId").val(), branchid, lobid).then(function (response) {
  1522. if (response.result != null) {
  1523. var seriesData = [];
  1524. if (response.result.length > 0) {
  1525. $(".txtSeriesAutoComplete_seriesid").empty();
  1526. for (let s = 0; s < response.result.length; s++) {
  1527. let Series = response.result[s];
  1528. seriesData.push({ id: Series.SeriesId, text: Series.SeriesName, AddlData: Series.ManualNumbering });
  1529. }
  1530. $('.txtSeriesAutoComplete_seriesid').select2({
  1531. data: seriesData,
  1532. });
  1533. $(".txtSeriesAutoComplete_seriesid").val(response.result[0].SeriesId).trigger("change");
  1534. }
  1535. else {
  1536. Unibase.Platform.Series.Managers.SeriesManager.Instance().getActiveSeries(0, Number($("#hf_FormInstalledAppId").val())).then(function (response) {
  1537. var data = response.result;
  1538. if (data != null) {
  1539. if (data.length != 0) {
  1540. $(".txtSeriesAutoComplete_seriesid").empty();
  1541. for (var s = 0; s < data.length; s++) {
  1542. let Series = data[s];
  1543. seriesData.push({ id: Series.SeriesId, text: Series.SeriesName, AddlData: Series.ManualNumbering });
  1544. }
  1545. $('.txtSeriesAutoComplete_seriesid').select2({
  1546. data: seriesData,
  1547. });
  1548. $(".txtSeriesAutoComplete_seriesid").val(data[0].SeriesId).trigger("change");
  1549. }
  1550. }
  1551. });
  1552. }
  1553. }
  1554. else {
  1555. Unibase.Platform.Series.Managers.SeriesManager.Instance().getActiveSeries(0, Number($("#hf_FormInstalledAppId").val())).then(function (response) {
  1556. var data = response.result;
  1557. if (data != null) {
  1558. if (data.length != 0) {
  1559. $(".txtSeriesAutoComplete_seriesid").empty();
  1560. for (var s = 0; s < data.length; s++) {
  1561. var Series = new Option(data[s].SeriesName, data[s].SeriesId.toString(), true);
  1562. $(".txtSeriesAutoComplete_seriesid").append(Series);
  1563. $(".txtSeriesAutoComplete_seriesid").val(data[s].SeriesId);
  1564. }
  1565. $(".txtSeriesAutoComplete_seriesid").val(data[0].SeriesId);
  1566. }
  1567. }
  1568. });
  1569. }
  1570. });
  1571. }
  1572. bindAdjustmentAccount(lobid, branchid) {
  1573. $('#hf_AdjustmentAccountId').val("0");
  1574. $('#txt_AdjustmentAccountName').empty();
  1575. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/ledgers/ledgermanager.js", function () {
  1576. Bizgaze.Apps.Transact.Managers.LedgerManager.Instance().getLobLedgerSetting(lobid, branchid).then(function (response) {
  1577. if (response.result != null && response.result != "") {
  1578. $("#txt_AdjustmentAccountName").append(new Option(response.result.LedgerName, response.result.SettingValue1, true));
  1579. $("#hf_AdjustmentAccountId").val(response.result.SettingValue1);
  1580. $("#txt_AdjustmentAccountName").val(response.result.SettingValue1);
  1581. }
  1582. });
  1583. });
  1584. }
  1585. bindDefaultPaymentTerm(organizationid, lobid) {
  1586. $('.hfAutoCompleteId_paymenttermid').val(0);
  1587. $('.txtAutoComplete_paymenttermid').empty();
  1588. Bizgaze.Apps.Transact.Managers.PaymentTermManager.Instance().getPaymentTermByOrg(organizationid, lobid).then(function (response) {
  1589. var paymentterm = response.result;
  1590. if (paymentterm != null && paymentterm != "") {
  1591. $('.hfAutoCompleteId_paymenttermid').val(paymentterm.PaymentTermId);
  1592. $('.txtAutoComplete_paymenttermid').append(new Option(paymentterm.PaymentTermName, paymentterm.PaymentTermId, true));
  1593. if (paymentterm.DueDays != null && paymentterm.DueDays > 0) {
  1594. var from = $('.date_journaldate').val().toString().split("/");
  1595. var f = new Date(Number(from[2]), Number(from[1]) - 1, Number(from[0]));
  1596. var currentdate = f.setDate(f.getDate() + paymentterm.DueDays);
  1597. $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(currentdate, ""));
  1598. let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(currentdate), "");
  1599. var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
  1600. $('.hfdate_duedate').val(tdate);
  1601. }
  1602. }
  1603. });
  1604. }
  1605. LoadContactDetails() {
  1606. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorganization($(".hfAutoCompleteId_orgcontactid").val()).then(function (response) {
  1607. if (response.result != null && response.result != "") {
  1608. if (response.result.CurrencyId != 0) {
  1609. $(".hdn_currencyid").val(response.result.CurrencyId);
  1610. $(".hdn_conversionrate").val(response.result.ConversionRate);
  1611. }
  1612. if (response.result.OrganizationTypeId == 1)
  1613. InvoiceItem.Instance().IswalkinCustomer = false;
  1614. else
  1615. InvoiceItem.Instance().IswalkinCustomer = true;
  1616. InvoiceItem.Instance().LoadSpocDetails($(".hfAutoCompleteId_orgcontactid").val());
  1617. }
  1618. else {
  1619. InvoiceItem.Instance().IswalkinCustomer = false;
  1620. InvoiceItem.Instance().LoadSpocDetails($(".hfAutoCompleteId_orgcontactid").val());
  1621. }
  1622. });
  1623. }
  1624. LoadSpocDetails(contactid) {
  1625. if ($('.hdn_invoicetypeid').val() == "1" || $('.hdn_invoicetypeid').val() == "6" || $('.hdn_invoicetypeid').val() == "4") {
  1626. $('.txtAutoComplete_billtoaddressid').empty();
  1627. $('.txtAutoComplete_shiptoaddressid').empty();
  1628. }
  1629. else {
  1630. $('.txtAutoComplete_billfromaddressid').empty();
  1631. $('.txtAutoComplete_shipfromaddressid').empty();
  1632. }
  1633. if ($(".hdn_invoiceid").val() == "0") {
  1634. $(".txtAutoComplete_LobId").empty();
  1635. $(".hfAutoCompleteId_LobId").empty();
  1636. }
  1637. $(".txtAutoComplete_salespersonid").empty();
  1638. $(".hfAutoCompleteId_salespersoid").empty();
  1639. if (InvoiceItem.Instance().IswalkinCustomer == true) {
  1640. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorganization(contactid).then(function (response) {
  1641. if (response.result != null) {
  1642. $(".hdn_organizationid").val(response.result.OrganizationId);
  1643. $("#hfInv_OrganizationName").val(response.result.OrganizationName);
  1644. 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) {
  1645. InvoiceItem.Instance().GetCustomerTurnOver();
  1646. }
  1647. $.when(InvoiceItem.Instance().loadAddressAutoCompletes(response.result.OrganizationId)).then(function () {
  1648. InvoiceItem.Instance().BindAddressDetails(response.result.OrganizationId);
  1649. InvoiceItem.Instance().GetAvailableWallets(0);
  1650. });
  1651. }
  1652. });
  1653. }
  1654. else {
  1655. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getorgcontact(contactid).then(function (response) {
  1656. var data = response.result;
  1657. if (response.result != null && data.OrganizationId != 0) {
  1658. $(".hdn_organizationid").val(response.result.OrganizationId);
  1659. $("#hfInv_OrganizationName").val(data.OrganizationName);
  1660. 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) {
  1661. InvoiceItem.Instance().GetCustomerTurnOver();
  1662. }
  1663. $.when(InvoiceItem.Instance().loadAddressAutoCompletes(response.result.OrganizationId)).then(function () {
  1664. InvoiceItem.Instance().BindAddressDetails(response.result.OrganizationId);
  1665. InvoiceItem.Instance().GetAvailableWallets(0);
  1666. });
  1667. }
  1668. });
  1669. }
  1670. }
  1671. GetJournalAlloc(invoiceId) {
  1672. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getJournalAllocs(invoiceId).then(function (response) {
  1673. if (response.result.length > 0)
  1674. $(".txtAutoComplete_orgcontactid").prop("disabled", true);
  1675. });
  1676. }
  1677. formatDate(date) {
  1678. var datearray = date.split("/");
  1679. var newdate = datearray[1] + '/' + datearray[0] + '/' + datearray[2];
  1680. var d = new Date(newdate), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear();
  1681. if (month.length < 2)
  1682. month = '0' + month;
  1683. if (month.length < 2)
  1684. month = '0' + month;
  1685. if (day.length < 2)
  1686. day = '0' + day;
  1687. return [year, month, day].join('-');
  1688. }
  1689. GetAvailableWallets(invoiceid) {
  1690. var ContactId = $(".hdn_organizationid").val();
  1691. var invoiceId = 0;
  1692. if (invoiceid != 0 && $('#hfInv_IsRetun').val() != "1") {
  1693. invoiceId = Number($(".hdn_invoiceid").val());
  1694. }
  1695. if (invoiceId != 0)
  1696. InvoiceItem.Instance().GetJournalAlloc(invoiceId);
  1697. var invoicedate = $('.date_journaldate').val();
  1698. var invdate = InvoiceItem.Instance().formatDate(invoicedate);
  1699. var lobId = $(".txtAutoComplete_lobid").val();
  1700. if (lobId == null || lobId == undefined)
  1701. lobId = 0;
  1702. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getJournalWallets(invdate, invoiceId, ContactId, Number($(".hdn_invoicetypeid").val()), lobId).then(function (response) {
  1703. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/controls/payments/wallet.component.js", function () {
  1704. if (response.result != null) {
  1705. Bizgaze.Apps.Transact.Controls.Wallet.Instance().loadInvoiceWallets(response.result);
  1706. }
  1707. });
  1708. });
  1709. }
  1710. BindAddressDetails(orgid) {
  1711. let branchid = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid"));
  1712. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getbranche(branchid).then(function (responce) {
  1713. if (responce.result != null) {
  1714. if (responce.result.DefaultWarehouseId != 0)
  1715. var ShipTo = new Option(responce.result.DefaultWarehouseName, responce.result.DefaultWarehouseId, true);
  1716. else
  1717. var ShipTo = new Option(responce.result.BranchName, responce.result.BranchId, true);
  1718. var BillTo = new Option(responce.result.BranchName, responce.result.BranchId, true);
  1719. if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") {
  1720. $(".txtAutoComplete_shiptoaddressid").append(ShipTo);
  1721. $(".txtAutoComplete_billtoaddressid").append(BillTo);
  1722. $(".txtAutoComplete_billtoaddressid").change(function () {
  1723. InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid").val(), $(".txtAutoComplete_billtoaddressid").val());
  1724. InvoiceItem.Instance().bindAdjustmentAccount($(".txtAutoComplete_lobid").val(), responce.result.BranchId);
  1725. });
  1726. }
  1727. else {
  1728. $(".txtAutoComplete_shipfromaddressid").append(ShipTo);
  1729. $(".txtAutoComplete_billfromaddressid").append(BillTo);
  1730. $(".txtAutoComplete_billfromaddressid").change(function () {
  1731. InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid").val(), $(".txtAutoComplete_billfromaddressid").val());
  1732. InvoiceItem.Instance().bindAdjustmentAccount($(".txtAutoComplete_lobid").val(), responce.result.BranchId);
  1733. });
  1734. }
  1735. }
  1736. });
  1737. this.fileCacheHelper.loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
  1738. Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressByContactId(orgid).then(function (response) {
  1739. if (response.result != null && response.result != "") {
  1740. var ShipTo = new Option(response.result.AddressName, response.result.ContactAddressId, true);
  1741. var BillTo = new Option(response.result.AddressName, response.result.ContactAddressId, true);
  1742. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "4") {
  1743. $(".txtAutoComplete_shiptoaddressid").append(ShipTo);
  1744. $(".txtAutoComplete_billtoaddressid").append(BillTo);
  1745. $(".txtAutoComplete_billtoaddressid").change(function () {
  1746. $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () {
  1747. InvoiceItem.Instance().BindLoB();
  1748. });
  1749. });
  1750. InvoiceItem.Instance().getGSTNo();
  1751. }
  1752. else {
  1753. $(".txtAutoComplete_shipfromaddressid").append(ShipTo);
  1754. $(".txtAutoComplete_billfromaddressid").append(BillTo);
  1755. $(".txtAutoComplete_billfromaddressid").change(function () {
  1756. $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () {
  1757. InvoiceItem.Instance().BindLoB();
  1758. });
  1759. });
  1760. InvoiceItem.Instance().getGSTNo();
  1761. }
  1762. if (response.result.GSTNO != "" && response.result.GSTNO != null)
  1763. $(".txt_gstno").val(response.result.GSTNO);
  1764. $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () {
  1765. InvoiceItem.Instance().BindLoB();
  1766. });
  1767. }
  1768. else {
  1769. MessageHelper.Instance().showError("Please assign billing address and shipping address", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  1770. }
  1771. });
  1772. });
  1773. }
  1774. getGSTNo() {
  1775. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  1776. var gstno = $(".txt_gstno").val();
  1777. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0 && Number($(".hdn_invoiceid").val()) != 0) {
  1778. gstno = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + InstalledAppId + "_gstno").Value;
  1779. }
  1780. $(".txt_gstno").parent().addClass("floating-label-form-group-with-value");
  1781. if (gstno != null && gstno != "") {
  1782. $(".txt_gstno").val(gstno);
  1783. }
  1784. else
  1785. $(".txt_gstno").val("GSTIN not Assigned");
  1786. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "4") {
  1787. $(".txtAutoComplete_billtoaddressid").change(function () {
  1788. Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(Number($(".txtAutoComplete_billtoaddressid").val())).then(function (ress) {
  1789. if (ress.result != null) {
  1790. if (ress.result.GSTNO != "" && ress.result.GSTNO != null)
  1791. $(".txt_gstno").val(ress.result.GSTNO);
  1792. }
  1793. });
  1794. });
  1795. }
  1796. else {
  1797. $(".txtAutoComplete_billfromaddressid").change(function () {
  1798. Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(Number($(".txtAutoComplete_billfromaddressid").val())).then(function (ress) {
  1799. if (ress.result != null) {
  1800. if (ress.result.GSTNO != "" && ress.result.GSTNO != null)
  1801. $(".txt_gstno").val(ress.result.GSTNO);
  1802. }
  1803. });
  1804. });
  1805. }
  1806. }
  1807. loadLobAndSp() {
  1808. var AddressId = $(".txtAutoComplete_billfromaddressid option:selected").val();
  1809. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "4")
  1810. AddressId = $(".txtAutoComplete_billtoaddressid option:selected").val();
  1811. var lobParameters = [{ "ColumnName": "contactaddressid", "Value": AddressId, }];
  1812. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_lobid"), lobParameters);
  1813. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/orders/ordermanager.js", function () {
  1814. var SpParameters = [{ "ColumnName": "contactaddressid", "Value": AddressId, }];
  1815. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_salespersonid"), null);
  1816. });
  1817. }
  1818. BindLoB() {
  1819. $(".txtAutoComplete_lobid").empty();
  1820. $('#hf_AdjustmentAccountId').val("0");
  1821. $('#txt_AdjustmentAccountName').empty();
  1822. if ($(".hdn_invoiceid").val() == "0") {
  1823. $(".InvoiceItems").find(".item-addedrow").remove();
  1824. InvoiceItem.Instance().SplitedInvoiceItemList = new Array();
  1825. InvoiceItem.Instance().itemIds = [0];
  1826. InvoiceItem.Instance().dcItemIds = [0];
  1827. $("#txt_Adjustment").val("0");
  1828. $("#span_Adjustment").text("0");
  1829. InvoiceItem.Instance().update_total();
  1830. InvoiceItem.Instance().TotalAdjustment();
  1831. }
  1832. var AddressId = $(".txtAutoComplete_billfromaddressid option:selected").val();
  1833. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6")
  1834. AddressId = $(".txtAutoComplete_billtoaddressid option:selected").val();
  1835. this.fileCacheHelper.loadJsFile("apps/crm/lobs/managers/lobmanager.js", function () {
  1836. if (AddressId == undefined) {
  1837. AddressId = 0;
  1838. }
  1839. Bizgaze.Apps.CRM.Lobs.Managers.LobManager.Instance().getLobsByAddressId(Number(AddressId)).then(function (response) {
  1840. if (response.message != '') {
  1841. Unibase.Platform.Forms.Components.FormViewer.Instance().showError(response.message);
  1842. }
  1843. if (response.result != "" && response.result != null) {
  1844. if (response.result.length == 1) {
  1845. var LoB = new Option(response.result[0].LobName, response.result[0].LobId, true);
  1846. $(".txtAutoComplete_lobid").append(LoB);
  1847. $(".txtAutoComplete_lobid").val(response.result[0].LobId);
  1848. InvoiceItem.Instance().BindSalesPerson(AddressId);
  1849. InvoiceItem.Instance().bindDefaultPaymentTerm($(".hdn_organizationid").val(), response.result[0].LobId);
  1850. var Addr = $(".txtAutoComplete_billtoaddressid option:selected").val();
  1851. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6")
  1852. Addr = $(".txtAutoComplete_billfromaddressid option:selected").val();
  1853. InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Addr);
  1854. InvoiceItem.Instance().bindAdjustmentAccount(response.result[0].LobId, Addr);
  1855. }
  1856. }
  1857. });
  1858. });
  1859. $(".txtAutoComplete_lobid").change(function () {
  1860. InvoiceItem.Instance().bindDefaultPaymentTerm($(".hdn_organizationid").val(), $(".txtAutoComplete_lobid option:selected").val());
  1861. var Address = $(".txtAutoComplete_billtoaddressid option:selected").val();
  1862. var Billto = $(".txtAutoComplete_billfromaddressid option:selected").val();
  1863. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6") {
  1864. Address = $(".txtAutoComplete_billfromaddressid option:selected").val();
  1865. Billto = $(".txtAutoComplete_billtoaddressid option:selected").val();
  1866. }
  1867. InvoiceItem.Instance().BindSalesPerson(Billto);
  1868. InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Address);
  1869. InvoiceItem.Instance().bindAdjustmentAccount($(".txtAutoComplete_lobid option:selected").val(), Address);
  1870. $(".InvoiceItems").find(".item-addedrow").remove();
  1871. InvoiceItem.Instance().SplitedInvoiceItemList = new Array();
  1872. InvoiceItem.Instance().itemIds = [0];
  1873. InvoiceItem.Instance().dcItemIds = [0];
  1874. $("#txt_Adjustment").val("0");
  1875. InvoiceItem.Instance().update_total();
  1876. InvoiceItem.Instance().TotalAdjustment();
  1877. InvoiceItem.Instance().GetAvailableWallets(0);
  1878. });
  1879. }
  1880. BindSalesPerson(AddressId) {
  1881. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
  1882. Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getManagerDetails(Number($(".txtAutoComplete_lobid option:selected").val()), AddressId).then(function (response) {
  1883. if (response.result != null) {
  1884. var SalesPerson = new Option(response.result.ManagerName, response.result.EmployeeId, true);
  1885. $(".txtAutoComplete_salespersonid").empty();
  1886. $(".txtAutoComplete_salespersonid").append(SalesPerson);
  1887. $(".txtAutoComplete_salespersonid").val(response.result.EmployeeId);
  1888. }
  1889. else {
  1890. $(".txtAutoComplete_salespersonid").empty();
  1891. $(".txtAutoComplete_salespersonid").val(0);
  1892. $(".txtAutoComplete_salespersonid").text("");
  1893. }
  1894. });
  1895. });
  1896. }
  1897. LoadDueDays() {
  1898. if (InvoiceItem.Instance().dcid != 0 && InvoiceItem.Instance().AutoDc == false && InvoiceItem.Instance().OrderSettingId != 2) {
  1899. var invdate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDate($('.date_journaldate').val());
  1900. if (InvoiceItem.Instance().DcDate != undefined) {
  1901. var date = InvoiceItem.Instance().DcDate.toString();
  1902. var dcdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
  1903. if (invdate < dcdate) {
  1904. var dctext = "DC";
  1905. if ($('.hdn_invoicetypeid').val() == "2")
  1906. dctext = "GRN";
  1907. MessageHelper.Instance().showError("Invoice Date should not be less than " + dctext + " Date", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  1908. }
  1909. }
  1910. }
  1911. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/paymentterms/paymenttermmanager.js", function () {
  1912. Bizgaze.Apps.Transact.Managers.PaymentTermManager.Instance().getPaymentTerm(Number($('.hfAutoCompleteId_paymenttermid').val())).then(function (result) {
  1913. if (result.result != null) {
  1914. if (result.result.DueDays > 0) {
  1915. if ($('.date_journaldate').val() == "") {
  1916. let todaydate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
  1917. $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""));
  1918. $('.hfdate_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""));
  1919. }
  1920. else {
  1921. var from = $('.date_journaldate').val().toString().split('/');
  1922. var f = new Date(Number(from[2]), Number(from[1]) - 1, Number(from[0]));
  1923. var currentdate = f.setDate(f.getDate() + result.result.DueDays);
  1924. var currentdate1 = f.setDate(f.getDate() + result.result.DueDays + 1);
  1925. $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(currentdate), ""));
  1926. let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(currentdate), "");
  1927. var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
  1928. $('.hfdate_duedate').val(tdate);
  1929. }
  1930. }
  1931. }
  1932. });
  1933. });
  1934. }
  1935. loadAddressAutoCompletes(organizationid) {
  1936. var ToAddressParameters = [{ "ColumnName": "contactid", "Value": organizationid, }];
  1937. let invoicetypeid = $(".hdn_invoicetypeid").val();
  1938. if (invoicetypeid == "1" || invoicetypeid == "4" || invoicetypeid == "6") {
  1939. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billtoaddressid"), ToAddressParameters);
  1940. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shiptoaddressid"), ToAddressParameters);
  1941. $(".txtAutoComplete_billtoaddressid").change(function () {
  1942. if (Number($(".hdn_invoiceid").val()) == 0) {
  1943. $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () {
  1944. InvoiceItem.Instance().BindLoB();
  1945. });
  1946. }
  1947. });
  1948. }
  1949. else {
  1950. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billfromaddressid"), ToAddressParameters);
  1951. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shipfromaddressid"), ToAddressParameters);
  1952. $(".txtAutoComplete_billfromaddressid").change(function () {
  1953. $.when(InvoiceItem.Instance().loadLobAndSp()).then(function () {
  1954. InvoiceItem.Instance().BindLoB();
  1955. });
  1956. });
  1957. }
  1958. var FromAddressParameters = [{ "ColumnName": "companyid", "Value": Number(Unibase.Platform.Membership.Infos.Identity.getSetting("companyid")) }];
  1959. if (invoicetypeid == "1" || invoicetypeid == "4" || invoicetypeid == "6") {
  1960. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billfromaddressid"), FromAddressParameters);
  1961. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shipfromaddressid"), FromAddressParameters);
  1962. }
  1963. else {
  1964. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_billtoaddressid"), FromAddressParameters);
  1965. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_shiptoaddressid"), FromAddressParameters);
  1966. }
  1967. }
  1968. loadControlSettings(controlsettingjson, formpropertyid) {
  1969. var instance = InvoiceItem.Instance();
  1970. $("#btnInvoiceItem").off().click(function () {
  1971. let lobid = $(".hfAutoCompleteId_lobid").val();
  1972. if (lobid == undefined || lobid == "" || lobid == "0") {
  1973. MessageHelper.Instance().showError("Please Select LoB", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  1974. return false;
  1975. }
  1976. else
  1977. InvoiceItem.instance.addRow();
  1978. });
  1979. $("#btndiscountItem").off().click(function () {
  1980. InvoiceItem.Instance().adddiscountrow(null, "", "", false);
  1981. });
  1982. instance.itemIds = new Array();
  1983. instance.dcItemIds = new Array();
  1984. instance.itemIds.push(0);
  1985. instance.dcItemIds.push(0);
  1986. instance.SplitedInvoiceItemList = new Array();
  1987. instance.deleted_invoiceItems = new Array();
  1988. instance.invItemTaxAdjustmentList = new Array();
  1989. instance.AutoDc = false;
  1990. instance.OrderSettingId = 0;
  1991. instance.orderid = 0;
  1992. instance.dcid = 0;
  1993. instance.IswalkinCustomer = false;
  1994. $('.inv_hdnfiels').empty();
  1995. var d = "<div class='inv_hdnfiels'></div>";
  1996. $(".section_CompanyDetails").prepend(d);
  1997. var hiddenfileds = "<input type='hidden' id='hfInv_OrganizationName' value=''/>" +
  1998. "<input type='hidden' id='hfInv_IsRetun' value='0'/>" +
  1999. "<input type='hidden' id='hfInv_wallet' value='false' />";
  2000. $('.inv_hdnfiels').append(hiddenfileds);
  2001. $(".hdn_branchid").val(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid"));
  2002. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  2003. for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
  2004. if (obj.Key === "hf_" + InstalledAppId + "_orderid") {
  2005. InvoiceItem.Instance().orderid = Number(Number(obj.Value));
  2006. $(".hdn_orderid").val(Number(obj.Value));
  2007. if (Number(obj.Value) != 0) {
  2008. for (let ob of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
  2009. if (ob.Key === "hf_" + InstalledAppId + "_branchid")
  2010. $(".hdn_branchid").val(ob.Value);
  2011. }
  2012. }
  2013. }
  2014. if (obj.Key === "hf_" + InstalledAppId + "_dcid") {
  2015. InvoiceItem.instance.dcid = Number(obj.Value);
  2016. $(".hdn_dcid").val(Number(obj.Value));
  2017. }
  2018. if (obj.Key === "hf_" + InstalledAppId + "_claimid") {
  2019. InvoiceItem.instance.ClaimId = Number(obj.Value);
  2020. }
  2021. if (obj.Key === "hf_" + InstalledAppId + "_dcdate") {
  2022. InvoiceItem.instance.DcDate = obj.Value;
  2023. }
  2024. }
  2025. if ((InvoiceItem.instance.dcid == 0 || InvoiceItem.instance.dcid == undefined) && (InvoiceItem.instance.dcid == 0 || InvoiceItem.instance.dcid == undefined)) {
  2026. instance.AutoDc = true;
  2027. }
  2028. InvoiceItem.Instance().invoiceinit();
  2029. $("#txt_taxAajustment").blur(function () {
  2030. InvoiceItem.Instance().update_total();
  2031. InvoiceItem.Instance().TotalAdjustment();
  2032. });
  2033. $("#txt_assessableadjustment").blur(function () {
  2034. InvoiceItem.Instance().update_total();
  2035. InvoiceItem.Instance().TotalAdjustment();
  2036. });
  2037. $(document).ready(function (e) {
  2038. if (Number($("#hf_pk_value").val()) != 0 && $("#chk_tdsapplied").is(":checked")) {
  2039. $(".divCustomProperties_tdstaxcodeid").removeClass('hidden');
  2040. $(".divCustomProperties_tdstaxrate").removeClass('hidden');
  2041. $(".divCustomProperties_tdsamount").removeClass('hidden');
  2042. }
  2043. else {
  2044. $(".divCustomProperties_tdstaxcodeid").addClass('hidden');
  2045. $(".divCustomProperties_tdstaxrate").addClass('hidden');
  2046. $(".divCustomProperties_tdsamount").addClass('hidden');
  2047. }
  2048. $("#chk_tdsapplied").removeAttr("onclick");
  2049. $("#chk_tdsapplied").change(function () {
  2050. if ($(this).prop('checked') == false) {
  2051. $(".txtAutoComplete_tdstaxcodeid").val(0);
  2052. $(".txtAutoComplete_tdstaxcodeid").text("");
  2053. $(".number_tdstaxrate").val(0);
  2054. $(".divCustomProperties_tdstaxcodeid").addClass('hidden');
  2055. $(".divCustomProperties_tdstaxrate").addClass('hidden');
  2056. $(".divCustomProperties_tdsamount").addClass('hidden');
  2057. $("#chk_tcsapplied").removeAttr("disabled");
  2058. $("#hdnchk_tdsapplied").val("false");
  2059. }
  2060. else {
  2061. $("#div_tcstaxrate").addClass("hidden");
  2062. $(".div_tcsadjustment").addClass("hidden");
  2063. $("#div_tcsamount").addClass("hidden");
  2064. $('#chk_tcsapplied').prop('checked', false);
  2065. $('#chk_tcsapplied').attr('disabled', "true");
  2066. $(".divCustomProperties_tdstaxcodeid").removeClass('hidden');
  2067. $(".divCustomProperties_tdstaxrate").removeClass('hidden');
  2068. $(".divCustomProperties_tdsamount").removeClass('hidden');
  2069. $("#chk_tcsapplied").attr("disabled");
  2070. $("#hdnchk_tdsapplied").val("true");
  2071. }
  2072. InvoiceItem.Instance().update_total();
  2073. });
  2074. $(".txtAutoComplete_tdstaxcodeid").change(function () {
  2075. $(".number_tdstaxrate").val(Number($(".txtAutoComplete_tdstaxcodeid").attr('data-addldata')));
  2076. InvoiceItem.Instance().update_total();
  2077. });
  2078. });
  2079. }
  2080. loadPropertySettings(propertysettings, formpropertyid) {
  2081. }
  2082. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  2083. }
  2084. bindEditInvoiceDetails(invoiceid) {
  2085. var VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  2086. $("#" + VisibleContainerId).find(".btn_Save_Form").removeClass("hidden");
  2087. if ($('.hdn_invoicetypeid').val() == "1" && $("#hf_AppSettingName").val() == "Create Return") {
  2088. $('#hfInv_IsRetun').val(1);
  2089. $('.hdn_invoicetypeid').val("3");
  2090. $(".txtSeriesAutoComplete_seriesid").prop("disabled", false);
  2091. $("#div_FormName").text("Create Sales Return");
  2092. $(".txtAutoComplete_orgcontactid").prop("disabled", true);
  2093. $(".hdn_journalno").val(0);
  2094. }
  2095. else if ($('.hdn_invoicetypeid').val() == "2" && $("#hf_AppSettingName").val() == "Create Return") {
  2096. $('#hfInv_IsRetun').val(1);
  2097. $('.hdn_invoicetypeid').val("4");
  2098. $(".txtSeriesAutoComplete_seriesid").prop("disabled", false);
  2099. $("#div_FormName").text("Create Purchase Return");
  2100. $(".txtAutoComplete_orgcontactid").prop("disabled", true);
  2101. $(".hdn_journalno").val(0);
  2102. }
  2103. let invoicetypeid = $('.hdn_invoicetypeid').val();
  2104. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/invoicemanager.js", function () {
  2105. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(invoiceid).then(function (result) {
  2106. var data = result.result;
  2107. var companyId = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("companyid"));
  2108. var Parameters = [];
  2109. if ($(".hdn_invoicetypeid").val() != "6" && $(".hdn_invoicetypeid").val() != "7")
  2110. Parameters = [{ "ColumnName": "companyid", "Value": companyId }];
  2111. Unibase.Forms.Controls.AutoComplete.Instance().LoadAutoComplete($(".txtAutoComplete_orgcontactid"), Parameters);
  2112. InvoiceItem.Instance().AutoDc = data.AutoDc;
  2113. if (data.OrgContactId == 0) {
  2114. InvoiceItem.Instance().IswalkinCustomer = true;
  2115. $(".hfAutoCompleteId_orgcontactid").val(data.OrganizationId);
  2116. var selectedCompany = new Option(data.OrganizationName, data.OrganizationId, true);
  2117. }
  2118. else {
  2119. InvoiceItem.Instance().IswalkinCustomer = false;
  2120. if (data.OrgContactName == null)
  2121. data.OrgContactName = "";
  2122. $(".hfAutoCompleteId_orgcontactid").val(data.OrgContactId);
  2123. var selectedCompany = new Option(data.OrganizationName + " - " + data.OrgContactName, data.OrgContactId, true);
  2124. }
  2125. $(".txtAutoComplete_orgcontactid").empty();
  2126. $(".txtAutoComplete_orgcontactid").append(selectedCompany);
  2127. if ($(".section_Details").hasClass('hidden')) {
  2128. $(".section_Details").removeClass('hidden');
  2129. }
  2130. if ($(".section_ItemDetails").hasClass('hidden')) {
  2131. $(".section_ItemDetails").removeClass('hidden');
  2132. }
  2133. if ($(".section_Ebs").hasClass('hidden')) {
  2134. $(".section_Ebs").removeClass('hidden');
  2135. }
  2136. if ($(".section_InvoiceAmount").hasClass('hidden')) {
  2137. $(".section_InvoiceAmount").removeClass('hidden');
  2138. }
  2139. if ($(".section_Description").hasClass('hidden')) {
  2140. $(".section_Description").removeClass('hidden');
  2141. }
  2142. if ($(".section_BillingAndShippingDetails").hasClass('hidden')) {
  2143. $(".section_BillingAndShippingDetails").removeClass('hidden');
  2144. }
  2145. if ($(".section_Wallets").hasClass('hidden')) {
  2146. $(".section_Wallets").removeClass("hidden");
  2147. }
  2148. if ($(".section_TCS").hasClass('hidden')) {
  2149. $(".section_TCS").removeClass("hidden");
  2150. }
  2151. $("#btn_Save").removeClass('hidden');
  2152. $(".txtAutoComplete_lobid").prop("disabled", true);
  2153. $(".txtAutoComplete_orgcontactid").prop("disabled", true);
  2154. if ($('#hfInv_IsRetun').val() == "1" && ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) {
  2155. let todaydate = Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate();
  2156. $('.date_journaldate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""));
  2157. var tdate = moment(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""), "DD/MM/YYYY").format("YYYY/MM/DD");
  2158. $('.hfdate_journaldate').val(tdate);
  2159. $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(todaydate), ""));
  2160. $('.hfdate_duedate').val(tdate);
  2161. InvoiceItem.Instance().LoadDueDays();
  2162. }
  2163. else {
  2164. $('.date_journaldate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(data.InvoiceDate, ""));
  2165. let date = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(data.InvoiceDate), "");
  2166. var tdate = moment(date, "DD/MM/YYYY").format("YYYY/MM/DD");
  2167. $('.hfdate_journaldate').val(tdate);
  2168. $('.date_duedate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(data.DueDate, ""));
  2169. var date1 = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(data.DueDate), "");
  2170. tdate = moment(date1, "DD/MM/YYYY").format("YYYY/MM/DD");
  2171. $('.hfdate_duedate').val(tdate);
  2172. }
  2173. $('.date_refdate').val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(data.RefDate, ""));
  2174. date1 = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDate1(new Date(data.RefDate), "");
  2175. tdate = moment(date1, "DD/MM/YYYY").format("YYYY/MM/DD");
  2176. $('.hfdate_refdate').val(tdate);
  2177. $.when(Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().loadAddressAutoCompletes(data.OrganizationId)).then(function (response) {
  2178. $(".txtAutoComplete_billfromaddressid").empty();
  2179. $(".txtAutoComplete_billtoaddressid").empty();
  2180. $(".txtAutoComplete_shiptoaddressid").empty();
  2181. $(".txtAutoComplete_shipfromaddressid").empty();
  2182. if ($('.hdn_invoicetypeid').val() == "1" || $('.hdn_invoicetypeid').val() == "4" || $('.hdn_invoicetypeid').val() == "6") {
  2183. $(".hfAutoCompleteId_billfromaddressid").val(data.BillFromAddressId);
  2184. $(".txtAutoComplete_billfromaddressid").append(new Option(data.BillFromAddressName, data.BillFromAddressId, true));
  2185. $(".hfAutoCompleteId_billtoaddressid").val(data.BillToAddressId);
  2186. $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillToAddressName, data.BillToAddressId, true));
  2187. $(".hfAutoCompleteId_shiptoaddressid").val(data.ShipToAddressId);
  2188. $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShipToAddressName, data.ShipToAddressId, true));
  2189. $(".hfAutoCompleteId_shipfromaddressid").val(data.ShipFromAddressId);
  2190. $(".txtAutoComplete_shipfromaddressid").append(new Option(data.ShipFromAddressName, data.ShipFromAddressId, true));
  2191. }
  2192. else {
  2193. $(".hfAutoCompleteId_billfromaddressid").val(data.BillToAddressId);
  2194. $(".txtAutoComplete_billfromaddressid").append(new Option(data.BillToAddressName, data.BillToAddressId, true));
  2195. $(".hfAutoCompleteId_billtoaddressid").val(data.BillFromAddressId);
  2196. $(".txtAutoComplete_billtoaddressid").append(new Option(data.BillFromAddressName, data.BillFromAddressId, true));
  2197. $(".hfAutoCompleteId_shiptoaddressid").val(data.ShipFromAddressId);
  2198. $(".txtAutoComplete_shiptoaddressid").append(new Option(data.ShipFromAddressName, data.ShipFromAddressId, true));
  2199. $(".hfAutoCompleteId_shipfromaddressid").val(data.ShipToAddressId);
  2200. $(".txtAutoComplete_shipfromaddressid").append(new Option(data.ShipToAddressName, data.ShipToAddressId, true));
  2201. }
  2202. InvoiceItem.Instance().loadLobAndSp();
  2203. InvoiceItem.Instance().getGSTNo();
  2204. $('.txtAutoComplete_lobid').empty();
  2205. $(".txtAutoComplete_lobid").append(new Option(data.LobName, data.LobId, true));
  2206. $(".hfAutoCompleteId_lobid").val(data.LobId);
  2207. $('.txtAutoComplete_salespersonid').empty();
  2208. $('.txtAutoComplete_salespersonid').append(new Option(data.SalesPersonName, data.SalesPersonId, true));
  2209. $('.hfAutoCompleteId_salespersonid').val(data.SalesPersonId);
  2210. $('hdn_OrganizationId').val(data.OrganizationId);
  2211. $("#hfInv_OrganizationName").val(data.OrganizationName);
  2212. $('.txtAutoComplete_paymenttermid').empty();
  2213. $('.hfAutoCompleteId_paymenttermid').val(data.PaymentTermId);
  2214. $('.txtAutoComplete_paymenttermid').append(new Option(data.PaymentTermName, data.PaymentTermId, true));
  2215. if (data.SeriesId != 0 && $('#hfInv_IsRetun').val() != "1") {
  2216. $(".txtSeriesAutoComplete_seriesid").empty();
  2217. $(".hfSeriesAutoCompleteId_seriesid").val(0);
  2218. $(".txtSeriesAutoComplete_seriesid").append(new Option(data.SeriesName, data.SeriesId, true));
  2219. $(".hfSeriesAutoCompleteId_seriesid").val(data.SeriesId);
  2220. }
  2221. else {
  2222. $(".txtSeriesAutoComplete_seriesid").prop("disabled", false);
  2223. if (data.SeriesId == 0 && data.InvoiceNo != null && data.InvoiceNo != "") {
  2224. $(".isManualSeries_seriesid").prop("checked", true);
  2225. $(".TextManualSeries").val(data.InvoiceNo);
  2226. }
  2227. else {
  2228. var Addr = $(".txtAutoComplete_billtoaddressid option:selected").val();
  2229. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6")
  2230. Addr = $(".txtAutoComplete_billfromaddressid option:selected").val();
  2231. InvoiceItem.Instance().bindSeries($(".txtAutoComplete_lobid option:selected").val(), Addr);
  2232. }
  2233. }
  2234. if (($('#hfInv_IsRetun').val() != "1") && ($('.hdn_invoicetypeid').val() == "4" || $('.hdn_invoicetypeid').val() == "7" || $('.hdn_invoicetypeid').val() == "6" || $('.hdn_invoicetypeid').val() == "3")) {
  2235. $(".txtSeriesAutoComplete_seriesid").prop("disabled", true);
  2236. }
  2237. if (data.RefNo != "" && data.RefNo != null)
  2238. $(".txt_refno").val(data.RefNo);
  2239. $(".hdn_refinvoiceid").val(data.RefInvoiceId);
  2240. if ($('#hfInv_IsRetun').val() == "1" && ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4"))
  2241. $(".txt_refno").val(data.InvoiceNo);
  2242. if (data.AdjustmentAccountId != 0) {
  2243. $("#txt_AdjustmentAccountName").append(new Option(data.AdjustmentAccountName, data.AdjustmentAccountId, true));
  2244. $("#txt_AdjustmentAccountName").val(data.AdjustmentAccountId);
  2245. $("#hf_AdjustmentAccountId").val(data.AdjustmentAccountId);
  2246. }
  2247. if (data.AdjustmentAccountId == 0)
  2248. $('#txt_AdjustmentAccountName').empty();
  2249. if (data.AutoAdjustment == true) {
  2250. $('#chk_AutoAdjustment').prop('checked', true);
  2251. $('#txt_Adjustment').prop("disabled", true);
  2252. $(".span_AdjustmentAccountName").removeClass('hidden');
  2253. $("#txt_AdjustmentAccountName").addClass('required');
  2254. }
  2255. else {
  2256. $('#chk_AutoAdjustment').prop('checked', false);
  2257. $('#txt_Adjustment').prop("disabled", false);
  2258. $("#txt_AdjustmentAccountName").removeClass('required');
  2259. $(".span_AdjustmentAccountName").addClass('hidden');
  2260. }
  2261. $('#txt_Adjustment').val(data.Adjustment);
  2262. if (data.Adjustment != 0) {
  2263. $('.span_AdjustmentAccountName').removeClass('hidden');
  2264. $("#txt_AdjustmentAccountName").addClass('required');
  2265. }
  2266. else {
  2267. $('.span_AdjustmentAccountName').addClass('hidden');
  2268. $("#txt_AdjustmentAccountName").removeClass('required');
  2269. }
  2270. if (data.InvoiceStatusId == 6) {
  2271. $('#btnInvoiceItem').hide();
  2272. }
  2273. var Iswalkincustomer = false;
  2274. var contactid = data.OrgContactId;
  2275. if (data.OrgContactId == 0) {
  2276. Iswalkincustomer = true;
  2277. contactid = data.OrganizationId;
  2278. }
  2279. InvoiceItem.Instance().IsCustomerIndustrial(data.LobId, data.OrganizationId);
  2280. $(".chk_excludefromcampaign").prop("checked", data.ExcludeFromCampaign);
  2281. $("#hfId_istaxinclusive").val(data.IsTaxInclusive);
  2282. InvoiceItem.Instance().isOfferChargeApplied = data.IsOfferChargeApplied;
  2283. $(".dropdown_istaxinclusive").val(data.IsTaxInclusive.toString());
  2284. $(".dropdown_paymentmethodid").val(data.PaymentMethodId);
  2285. InvoiceItem.Instance().GetAvailableWallets(data.InvoiceId);
  2286. InvoiceItem.Instance().loadOrderPendingItems();
  2287. });
  2288. $(".txtAutoComplete_orgcontactid").change(function () {
  2289. InvoiceItem.Instance().LoadContactDetails();
  2290. });
  2291. if (data.GSTNO != "" && data.GSTNO != null)
  2292. $(".txt_gstno").val(data.GSTNO);
  2293. 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) {
  2294. if (res.result != null) {
  2295. InvoiceItem.Instance().TurnOver = res.result.TurnOver;
  2296. InvoiceItem.Instance().ContactTcsEnable = res.result.Enable;
  2297. InvoiceItem.Instance().EnableTenantTcs = res.result.EnableTenantTcs;
  2298. InvoiceItem.Instance().PanAvailable = res.result.PanAvailable;
  2299. InvoiceItem.Instance().TaxRate = res.result.TaxRate;
  2300. $(".hdn_tcstaxcodeaccountid").val(res.result.TCSTaxCodeAccountId);
  2301. $(".hdn_tcstaxcodeid").val(res.result.TCSTaxCodeId);
  2302. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2") {
  2303. if (InvoiceItem.Instance().ContactTcsEnable == true && InvoiceItem.Instance().EnableTenantTcs == true && data.TcsApplied == true) {
  2304. $("#chk_tcsapplied").prop("checked", true);
  2305. $("#hdnchk_tcsapplied").val("true");
  2306. $("#div_tcstaxrate").removeClass("hidden");
  2307. $(".div_tcsadjustment").removeClass("hidden");
  2308. $("#div_tcsamount").removeClass("hidden");
  2309. $(".number_tcsamount").prop("disabled", true);
  2310. }
  2311. }
  2312. }
  2313. });
  2314. $("chk_tcsapplies").prop("checked", data.TcsApplied);
  2315. $(".hdn_tcstaxcodeid").val(data.TcsTaxCodeId);
  2316. $(".hdn_tcstaxcodeaccountid").val(data.TcsTaxCodeAccountId);
  2317. $(".number_tcstaxrate").val(data.TcsTaxRate);
  2318. $(".number_tcstaxrate").prop("disabled", true);
  2319. $(".txt_tcsadjustment").val(data.TcsAdjustment);
  2320. $(".number_tcsamount").val(data.TcsAmount);
  2321. $(".number_tcsamount").prop("disabled", true);
  2322. $(".number_tdsamount").prop("disabled", true);
  2323. $(".number_tdstaxrate").prop("disabled", true);
  2324. InvoiceItem.Instance().ContactTcsEnable = data.TcsApplied;
  2325. InvoiceItem.Instance().TaxRate = data.TcsTaxRate;
  2326. if (data.TcsApplied == true) {
  2327. $("#div_tcstaxrate").removeClass("hidden");
  2328. $(".div_tcsadjustment").removeClass("hidden");
  2329. $("#div_tcsamount").removeClass("hidden");
  2330. }
  2331. else {
  2332. $("#div_tcstaxrate").addClass("hidden");
  2333. $(".div_tcsadjustment").addClass("hidden");
  2334. $("#div_tcsamount").addClass("hidden");
  2335. }
  2336. $("#chk_tcsapplied").unbind();
  2337. $("#chk_tcsapplied").change(function () {
  2338. if ($('#chk_AutoAdjustment').prop("checked") == true) {
  2339. $("#txt_Adjustment").val(0);
  2340. $(".hdn_adjustment").val(0);
  2341. }
  2342. if ($(this).prop('checked') == true) {
  2343. $(".divCustomProperties_tdstaxrate").addClass("hidden");
  2344. $(".divCustomProperties_tdsamount").addClass("hidden");
  2345. $(".divCustomProperties_tdstaxcodeid").addClass("hidden");
  2346. $(".chk_tdsapplied").attr("disabled");
  2347. $('#chk_tdsapplied').prop('checked', false);
  2348. }
  2349. else {
  2350. $(".chk_tdsapplied").removeAttr("disabled");
  2351. }
  2352. $(".div_tcsadjustment").addClass("floating-label-form-group-with-value");
  2353. if ($(this).prop('checked') == true && InvoiceItem.Instance().EnableTenantTcs == false && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) {
  2354. MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  2355. $("#hdnchk_tcsapplied").val("false");
  2356. $('#chk_tcsapplied').prop('checked', false);
  2357. }
  2358. else {
  2359. if ($(this).prop('checked') == true && $(".hdn_invoicetypeid").val() == "1") {
  2360. bootbox.confirm("Confirm if sale value is > 50,00,000 for this customer.In this current Financial Year.", function (result) {
  2361. if (result) {
  2362. $("#div_tcstaxrate").removeClass("hidden");
  2363. $(".div_tcsadjustment").removeClass("hidden");
  2364. $("#div_tcsamount").removeClass("hidden");
  2365. InvoiceItem.Instance().update_total();
  2366. InvoiceItem.Instance().TotalAdjustment();
  2367. }
  2368. else {
  2369. $("#div_tcstaxrate").addClass("hidden");
  2370. $(".div_tcsadjustment").addClass("hidden");
  2371. $("#div_tcsamount").addClass("hidden");
  2372. $('#chk_tcsapplied').prop('checked', false);
  2373. InvoiceItem.Instance().update_total();
  2374. InvoiceItem.Instance().TotalAdjustment();
  2375. }
  2376. });
  2377. }
  2378. else if ($(this).prop('checked') == true) {
  2379. $("#div_tcstaxrate").removeClass("hidden");
  2380. $(".div_tcsadjustment").removeClass("hidden");
  2381. $("#div_tcsamount").removeClass("hidden");
  2382. $("#chk_tdsapplied").removeAttr("disabled");
  2383. InvoiceItem.Instance().update_total();
  2384. InvoiceItem.Instance().TotalAdjustment();
  2385. }
  2386. else if ($(this).prop('checked') == false) {
  2387. $("#div_tcstaxrate").addClass("hidden");
  2388. $(".div_tcsadjustment").addClass("hidden");
  2389. $("#div_tcsamount").addClass("hidden");
  2390. $(".number_tcstaxrate").val(data.TcsTaxRate);
  2391. $(".number_tcstaxrate").prop("disabled", true);
  2392. $(".txt_tcsadjustment").val(data.TcsAdjustment);
  2393. $(".number_tcsamount").val(data.TcsAmount);
  2394. $(".number_tcsamount").prop("disabled", true);
  2395. InvoiceItem.Instance().update_total();
  2396. InvoiceItem.Instance().TotalAdjustment();
  2397. }
  2398. }
  2399. });
  2400. if ($("#chk_tdsapplied").prop('checked') == false) {
  2401. $(".divCustomProperties_tdstaxrate").addClass("hidden");
  2402. $(".divCustomProperties_tdsamount").addClass("hidden");
  2403. $(".divCustomProperties_tdstaxcodeid").addClass("hidden");
  2404. }
  2405. else
  2406. $("#chk_tcsapplied").attr("disabled");
  2407. $(".txt_tcsadjustment").unbind();
  2408. $(".txt_tcsadjustment").blur(function () {
  2409. InvoiceItem.Instance().update_total();
  2410. InvoiceItem.Instance().TotalAdjustment();
  2411. });
  2412. });
  2413. });
  2414. }
  2415. loadOrderPendingItems() {
  2416. var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  2417. let instance = this;
  2418. let invoiceid = $(".hdn_invoiceid").val();
  2419. var orderid = $(".hdn_orderid").val();
  2420. var Dcid = $(".hdn_dcid").val();
  2421. var fromOrder = false;
  2422. var items = [];
  2423. var Invoiceitem = [];
  2424. $(".item-addedrow").remove();
  2425. var url = "";
  2426. if (Dcid != 0 && Dcid != undefined && orderid == 0) {
  2427. fromOrder = false;
  2428. url = "apis/v4/bizgaze/transact/Dc/getpendingdcitemsforinvoice/dcid/" + Dcid;
  2429. }
  2430. if (Dcid == 0 || Dcid == undefined || InvoiceItem.Instance().OrderSettingId == 2) {
  2431. if (orderid != "0" && orderid != undefined) {
  2432. fromOrder = true;
  2433. url = "apis/v4/bizgaze/transact/Orders/getpendingitemsforinvoice/orderid/" + orderid + "/ismergeorder/false";
  2434. }
  2435. }
  2436. else if (Dcid != 0 && Dcid != undefined) {
  2437. fromOrder = false;
  2438. url = "apis/v4/bizgaze/transact/Dc/getpendingdcitemsforinvoice/dcid/" + Dcid;
  2439. }
  2440. if (invoiceid != 0 && invoiceid != undefined && invoiceid != "null") {
  2441. fromOrder = false;
  2442. if ($('#hfInv_IsRetun').val() == "1") {
  2443. if ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")
  2444. url = "apis/v4/bizgaze/transact/invoices/getinvoiceitemsbyinvoiceid/invoiceid/" + invoiceid + "/isreturn/true/itemid/0";
  2445. }
  2446. else
  2447. url = "apis/v4/bizgaze/transact/invoices/getinvoiceitemsbyinvoiceid/invoiceid/" + invoiceid + "/isreturn/false/itemid/0";
  2448. }
  2449. if (url != "") {
  2450. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceItems(url).then(function (response) {
  2451. var oldTaxId = 0;
  2452. var totalQty = 0;
  2453. if (response.result != null && response.result.length > 0)
  2454. instance.ShowOrHideSaveBtn(false);
  2455. for (var i = 0; i < response.result.length; i++) {
  2456. var item = response.result[i];
  2457. var invoiceItemId = 0;
  2458. totalQty += item.Quantity;
  2459. if (invoiceid != "0" && invoiceid != undefined && invoiceid != "null") {
  2460. invoiceItemId = item.InvoiceItemId;
  2461. item.IsOfferChargeApplied = InvoiceItem.Instance().isOfferChargeApplied;
  2462. }
  2463. InvoiceItem.Instance().isOfferChargeApplied = true;
  2464. $(".hdn_isofferchargeapplied").val('true');
  2465. var refInvoiceItemId = 0;
  2466. if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $("#hf_AppSettingName").val() == "Create Return")
  2467. refInvoiceItemId = item.InvoiceItemId;
  2468. if (i == 0)
  2469. oldTaxId = item.TaxGroupId;
  2470. if (oldTaxId != item.TaxGroupId && i != 0)
  2471. $('#addDiscount').addClass('hidden');
  2472. var maxQty = 0;
  2473. if (item.OrderItemPendingQty > 0)
  2474. maxQty = item.OrderItemPendingQty;
  2475. var pendingQuantity = item.OrderItemPendingQty > 0 ? item.OrderItemPendingQty : 0;
  2476. if (invoiceItemId != 0) {
  2477. maxQty = item.Quantity + pendingQuantity;
  2478. if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4"))
  2479. maxQty = item.Quantity;
  2480. }
  2481. if (item.DcItemId == undefined)
  2482. item.DcItemId = 0;
  2483. if (item.TaxAdjustment == undefined)
  2484. item.TaxAdjustment = 0;
  2485. if (item.AssesableAdjustment == undefined)
  2486. item.AssesableAdjustment = 0;
  2487. if (item.IsFoc == undefined)
  2488. item.IsFoc = false;
  2489. if (item.OfferItemId == undefined)
  2490. item.OfferItemId = 0;
  2491. if (item.DiscountPercent == undefined)
  2492. item.DiscountPercent = 0;
  2493. if (item.DiscountValue == undefined)
  2494. item.DiscountValue = 0;
  2495. if (item.IsSpecialPrice == undefined)
  2496. item.IsSpecialPrice = false;
  2497. if (item.MrpId == 0)
  2498. item.EnableMRP = false;
  2499. var itemRow = {
  2500. orderItemId: item.OrderItemId,
  2501. invoiceItemId: invoiceItemId,
  2502. itemName: item.ItemName,
  2503. itemId: item.ItemId,
  2504. itemSKU: item.ItemSKU,
  2505. unitName: item.UnitName,
  2506. packSize: item.PackSize,
  2507. packCount: item.PackCount,
  2508. packs: item.Packs,
  2509. quantity: item.Quantity,
  2510. availPacks: item.AvailablePacks,
  2511. availQty: item.AvailableQty,
  2512. listPrice: 0,
  2513. description: item.Description,
  2514. taxGroupName: item.TaxGroupName,
  2515. taxGroupId: item.TaxGroupId,
  2516. isTaxInclusive: $("#hfId_istaxinclusive").val(),
  2517. addlDiscountPercent: item.DiscountPercent,
  2518. addlDiscountValue: item.DiscountAmount,
  2519. creditNote: 0,
  2520. priceListId: 0,
  2521. batchId: 0,
  2522. unitPrice: item.UnitPrice,
  2523. invoiceallocations: null,
  2524. exciseInvoiceItem: null,
  2525. accountId: item.LedgerId,
  2526. accountName: item.LedgerName,
  2527. walletId: 0,
  2528. Adjustment: 0,
  2529. IsFoc: item.IsFoc,
  2530. TariffNo: "",
  2531. exciseAmount: item.ExciseAmount,
  2532. discountName: "",
  2533. discountId: 0,
  2534. refNo: item.RefNo,
  2535. DiscountGroupId: item.DiscountGroupId,
  2536. DiscountGroupName: item.DiscountGroupName,
  2537. ExchangeItem: item.ExchangeDC,
  2538. maxQty: maxQty,
  2539. RefInvoiceItemId: refInvoiceItemId,
  2540. MrpId: item.MrpId,
  2541. taxAdjustment: item.TaxAdjustment,
  2542. assesableAdjustment: item.AssesableAdjustment,
  2543. inventoryTypeId: item.InventoryTypeId,
  2544. IsBoMItem: item.IsBoMItem,
  2545. dcItemId: item.DcItemId,
  2546. TotalRowAmount: 0,
  2547. TotalDiscount: 0,
  2548. BatchId: item.BatchId,
  2549. OfferItemId: item.OfferItemId,
  2550. AlternateUnitId: item.AlternateUnitId,
  2551. DefaultSize: item.DefaultSize,
  2552. ParentBOMItemId: item.ParentBOMItemId,
  2553. IsSpecialPrice: item.IsSpecialPrice,
  2554. IsMultipleUOMs: item.IsMultipleUOMs,
  2555. MultipleUoms: item.MultipleUOMs,
  2556. IsManualUOM: item.IsManualUOM,
  2557. ConversionQuantity: item.ConversionQuantity,
  2558. AlternateUnitName: item.AlternateUnitName,
  2559. };
  2560. var EnableMrp = item.EnableMRP;
  2561. var EnableBatch = item.EnableBatch;
  2562. if (item.IsFoc == true)
  2563. Invoiceitem.push(itemRow);
  2564. else if (item.DcItemId != 0 && EnableMrp != true && EnableBatch != true)
  2565. Invoiceitem.push(itemRow);
  2566. else if (item.InvoiceItemId == 0) {
  2567. 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)
  2568. Invoiceitem.push(itemRow);
  2569. }
  2570. else if (item.InvoiceItemId == 0) {
  2571. 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))
  2572. Invoiceitem.push(itemRow);
  2573. }
  2574. else if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && ((EnableMrp != true && EnableBatch != true)))
  2575. Invoiceitem.push(itemRow);
  2576. else if (($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3") && EnableMrp != true && EnableBatch != true)
  2577. Invoiceitem.push(itemRow);
  2578. else if ($(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7")
  2579. Invoiceitem.push(itemRow);
  2580. else {
  2581. if (item.InventoryTypeId != 5 && item.InventoryTypeId != 6 && item.InventoryTypeId != 7) {
  2582. var total = Number((itemRow.quantity * itemRow.unitPrice) + itemRow.exciseAmount + itemRow.Adjustment + itemRow.assesableAdjustment);
  2583. var nonexcise = total - itemRow.exciseAmount;
  2584. var disc = ((nonexcise * itemRow.addlDiscountPercent) / 100) + (itemRow.quantity * itemRow.addlDiscountValue);
  2585. var Rowtotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(total - disc, 3);
  2586. InvoiceItem.Instance().SplitedInvoiceItemList.push({
  2587. orderItemId: item.OrderItemId,
  2588. invoiceItemId: invoiceItemId,
  2589. itemName: item.ItemName,
  2590. itemId: item.ItemId,
  2591. itemSKU: item.ItemSKU,
  2592. unitName: item.UnitName,
  2593. packSize: item.PackSize,
  2594. packCount: item.PackCount,
  2595. packs: item.Packs,
  2596. quantity: item.Quantity,
  2597. availPacks: item.AvailablePacks,
  2598. availQty: item.AvailableQty,
  2599. listPrice: 0,
  2600. description: item.Description,
  2601. taxGroupName: item.TaxGroupName,
  2602. taxGroupId: item.TaxGroupId,
  2603. isTaxInclusive: $("#hfId_istaxinclusive").val(),
  2604. addlDiscountPercent: item.DiscountPercent,
  2605. addlDiscountValue: item.DiscountAmount,
  2606. creditNote: 0,
  2607. priceListId: 0,
  2608. batchId: 0,
  2609. unitPrice: item.UnitPrice,
  2610. invoiceallocations: null,
  2611. exciseInvoiceItem: null,
  2612. accountId: item.LedgerId,
  2613. accountName: item.LedgerName,
  2614. walletId: 0,
  2615. Adjustment: 0,
  2616. IsFoc: 0,
  2617. TariffNo: "",
  2618. exciseAmount: item.ExciseAmount,
  2619. discountName: "",
  2620. discountId: 0,
  2621. refNo: item.RefNo,
  2622. DiscountGroupId: item.DiscountGroupId,
  2623. DiscountGroupName: item.DiscountGroupName,
  2624. ExchangeItem: item.ExchangeDC,
  2625. maxQty: maxQty,
  2626. RefInvoiceItemId: refInvoiceItemId,
  2627. MrpId: item.MrpId,
  2628. taxAdjustment: item.TaxAdjustment,
  2629. assesableAdjustment: item.AssesableAdjustment,
  2630. inventoryTypeId: item.InventoryTypeId,
  2631. IsBoMItem: item.IsBoMItem,
  2632. dcItemId: item.DcItemId,
  2633. TotalRowAmount: Rowtotal,
  2634. TotalDiscount: disc,
  2635. BatchId: item.BatchId,
  2636. TotalAmount: Rowtotal,
  2637. ParentBOMItemId: item.ParentBOMItemId
  2638. });
  2639. if (items.length != 0 && items.find(x => x.itemId == item.ItemId) != undefined) {
  2640. var multipleExist = items.find(x => x.itemId == item.ItemId);
  2641. multipleExist.quantity += itemRow.quantity;
  2642. var RowTotal = 0;
  2643. var rowtotal = Number((itemRow.quantity * itemRow.unitPrice) + itemRow.exciseAmount + itemRow.Adjustment + itemRow.assesableAdjustment);
  2644. var nonexiceamount = rowtotal - itemRow.exciseAmount;
  2645. var discount = ((nonexiceamount * itemRow.addlDiscountPercent) / 100) + (itemRow.quantity * itemRow.addlDiscountValue);
  2646. discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3));
  2647. RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3);
  2648. multipleExist.TotalRowAmount = Number(multipleExist.TotalRowAmount) + Number(RowTotal);
  2649. multipleExist.TotalDiscount = Number(multipleExist.TotalDiscount) + Number(discount);
  2650. if (InvoiceItem.Instance().OrderSettingId == 1) {
  2651. var Qty = Number(maxQty);
  2652. multipleExist.maxQty = Qty + Number(multipleExist.maxQty);
  2653. }
  2654. else {
  2655. var Qty = Number(item.Quantity);
  2656. multipleExist.maxQty = Qty + Number(multipleExist.maxQty);
  2657. }
  2658. }
  2659. else {
  2660. var RowTotal = 0;
  2661. var rowtotal = Number((itemRow.quantity * itemRow.unitPrice) + itemRow.exciseAmount + itemRow.Adjustment + itemRow.assesableAdjustment);
  2662. var nonexiceamount = rowtotal - itemRow.exciseAmount;
  2663. var discount = ((nonexiceamount * itemRow.addlDiscountPercent) / 100) + (itemRow.quantity * itemRow.addlDiscountValue);
  2664. discount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discount, 3));
  2665. RowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowtotal - discount, 3);
  2666. itemRow.TotalRowAmount = Number(itemRow.TotalRowAmount) + Number(RowTotal);
  2667. itemRow.TotalDiscount = Number(discount);
  2668. items.push(itemRow);
  2669. }
  2670. }
  2671. else {
  2672. Invoiceitem.push(itemRow);
  2673. }
  2674. }
  2675. $.each(item.InvItemTaxAdjustments, function (e) {
  2676. var data = $(this);
  2677. var rowData = data[0];
  2678. InvoiceItem.Instance().invItemTaxAdjustmentList.push(rowData);
  2679. });
  2680. }
  2681. for (let j1 = 0; j1 < items.length; j1++) {
  2682. let j = items[j1];
  2683. var emptyRow = {
  2684. orderItemId: j.orderItemId,
  2685. invoiceItemId: 0,
  2686. itemName: j.itemName,
  2687. itemId: j.itemId,
  2688. itemSKU: j.itemSKU,
  2689. unitName: "",
  2690. packSize: 0,
  2691. packCount: 0,
  2692. packs: 0,
  2693. quantity: j.quantity,
  2694. availPacks: 0,
  2695. availQty: j.availQty,
  2696. listPrice: 0,
  2697. description: "",
  2698. taxGroupName: j.taxGroupName,
  2699. taxGroupId: j.taxGroupId,
  2700. isTaxInclusive: $("#hf_istaxinclusive").val(),
  2701. addlDiscountPercent: 0,
  2702. addlDiscountValue: j.addlDiscountValue,
  2703. creditNote: 0,
  2704. priceListId: 0,
  2705. batchId: 0,
  2706. unitPrice: j.unitPrice,
  2707. invoiceallocations: null,
  2708. exciseInvoiceItem: null,
  2709. accountId: j.accountId,
  2710. accountName: j.accountName,
  2711. walletId: 0,
  2712. Adjustment: 0,
  2713. IsFoc: j.IsFoc,
  2714. TariffNo: "",
  2715. exciseAmount: 0,
  2716. discountName: "",
  2717. discountId: 0,
  2718. refNo: "",
  2719. DiscountGroupId: 0,
  2720. DiscountGroupName: '',
  2721. RefInvoiceItemId: 0,
  2722. MrpId: j.MrpId,
  2723. taxAdjustment: 0,
  2724. assesableAdjustment: 0,
  2725. inventoryTypeId: 0,
  2726. dcItemId: 0,
  2727. TotalRowAmount: j.TotalRowAmount,
  2728. BatchId: j.BatchId,
  2729. maxQty: j.maxQty,
  2730. TotalDiscount: j.TotalDiscount,
  2731. ParentBOMItemId: j.ParentBOMItemId,
  2732. IsSpecialPrice: j.IsSpecialPrice
  2733. };
  2734. if (j.dcItemId != 0)
  2735. InvoiceItem.Instance().dcItemIds.push(j.dcItemId);
  2736. InvoiceItem.Instance().addDataRow(emptyRow, true);
  2737. if (items.length - 1 == j1) {
  2738. if (invoiceid != 0)
  2739. instance.GetDiscounts();
  2740. instance.ShowOrHideSaveBtn(true);
  2741. }
  2742. }
  2743. for (let k1 = 0; k1 < Invoiceitem.length; k1++) {
  2744. let k = Invoiceitem[k1];
  2745. if (k.dcItemId != 0)
  2746. InvoiceItem.Instance().dcItemIds.push(k.dcItemId);
  2747. InvoiceItem.Instance().addDataRow(k, false);
  2748. if (Invoiceitem.length - 1 == k1) {
  2749. if (invoiceid != 0)
  2750. instance.GetDiscounts();
  2751. instance.ShowOrHideSaveBtn(true);
  2752. }
  2753. }
  2754. $("#totalinvoiceqty").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalQty, 2));
  2755. });
  2756. }
  2757. }
  2758. getwalletinvoiceditems() {
  2759. var JournalAlloc = new Array();
  2760. $("#tbl_WalletItems").find(".walletitem-addedrow").each(function () {
  2761. JournalAlloc.push({
  2762. journalAllocId: $(this).find(".journalAllocId").val(),
  2763. RefAllocId: $(this).find(".refAllocId").val(),
  2764. JournalId: $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_Invoiceid").val(),
  2765. AdjustedAmount: Number($(this).find(".hfAdjustedAmount").val()),
  2766. TotalAmount: Number($(this).find(".totalAmount").text()),
  2767. IsWallet: true,
  2768. CurrentAmount: Number($(this).find(".currentAmount").val()),
  2769. });
  2770. });
  2771. return JournalAlloc;
  2772. }
  2773. ShowOrHideSaveBtn(IsShow) {
  2774. let instance = this;
  2775. if (!IsShow) {
  2776. instance.navigationHelper.showLoading();
  2777. $("#btnDynamicSave").prop("disabled", true);
  2778. }
  2779. else {
  2780. instance.navigationHelper.hideLoading();
  2781. $("#btnDynamicSave").prop("disabled", false);
  2782. }
  2783. }
  2784. getInvoiceItems() {
  2785. var invItemList = new Array();
  2786. $(".InvoiceItems").find(".item-row").each(function () {
  2787. if (!$(this).hasClass('SplitItem')) {
  2788. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  2789. let ParentBOMItemId = $(this).find(".hf_ParentBOMItemId").val();
  2790. if (ParentBOMItemId == null)
  2791. ParentBOMItemId = 0;
  2792. var invoicetermid = $(this).find(".invoiceTermId").val();
  2793. var invoiceitemid = Number($(this).find(".selectedInvoiceItemId").val());
  2794. var refInvoiceitemid = Number($(this).find(".refInvoiceItemId").val());
  2795. var orderItemId = Number($(this).find(".orderItemId").val());
  2796. var ItemId = Number($(this).find(".selectedItemId").val());
  2797. var packs = 0;
  2798. var prodprice = Number($(this).find(".prodPrice").val());
  2799. var quantity = Number($(this).find(".prodQuantity").val());
  2800. var prodpricelist = 0;
  2801. var description = $(this).find(".prodDesc").val();
  2802. var MrpId = Number($(this).find(".hfMrpId").val());
  2803. var discountAmount = 0;
  2804. var discountPercent = 0;
  2805. var rowTotal = Number($(this).find(".prodTotalPrice").text());
  2806. if (($(".hdn_invoicetypeid").val() == "2") && invoiceitemid != 0) {
  2807. rowTotal = Number($(this).find(".hfRowTotalwithAdjustment").val());
  2808. }
  2809. var Quantity = Number($(this).find(".prodQuantity").val());
  2810. var ConversionQuantity = Quantity;
  2811. let SelectedUnitId = 0;
  2812. let DefaultSize = 0;
  2813. let AlternateSize = 0;
  2814. if ($(this).find(".hf_IsMultipleUOM").val() == "true" && $(".hdn_invoicetypeid").val() == "1") {
  2815. let ItemId = Number($(this).find(".selectedItemId").val());
  2816. SelectedUnitId = Number($(this).find(".ddl_MultipleUOMs").val());
  2817. if (SelectedUnitId != 0 && SelectedUnitId != 1) {
  2818. var Uom = InvoiceItem.Instance().UOMs.find(x => x.ItemId == ItemId);
  2819. var SelectedUOM = Uom.MultipleUOMs.find(x => x.SchemaDetailId == SelectedUnitId);
  2820. DefaultSize = SelectedUOM.DefaultSize;
  2821. AlternateSize = SelectedUOM.AlternateSize;
  2822. ConversionQuantity = Number(Quantity) * (AlternateSize / DefaultSize);
  2823. }
  2824. }
  2825. else if ($(this).find(".hf_IsManualUOM").val() == "true" && $(".hdn_invoicetypeid").val() == "1") {
  2826. SelectedUnitId = Number($(this).find(".hf_AlternateUnitId").val());
  2827. ConversionQuantity = Number($(this).find(".hf_ConversionQuantity").val());
  2828. }
  2829. 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) {
  2830. discountAmount = Number($(this).find('.inv_txtaddldiscount').val());
  2831. }
  2832. else if ($(this).find(".btnInvoice_DiscType option:selected").text().trim() == '%' && $(this).find('.inv_txtaddldiscount').val() != '' && $(this).find('.inv_txtaddldiscount').val() != undefined) {
  2833. discountPercent = Number($(this).find('.inv_txtaddldiscount').val());
  2834. }
  2835. var TaxGroupId = Number($(this).find(".hfProdTax").val());
  2836. let accountid = Number($(this).find(".txt_Account").val());
  2837. let foc = ($(this).find(".hf_IsFoc").val() == 'true');
  2838. invItemList.push({
  2839. InvoiceItemId: invoiceitemid,
  2840. OrderItemId: orderItemId,
  2841. ItemId: ItemId,
  2842. Packs: packs,
  2843. TaxGroupId: TaxGroupId,
  2844. Description: description,
  2845. PriceListId: prodpricelist,
  2846. UnitPrice: prodprice,
  2847. DiscountAmount: discountAmount,
  2848. DiscountPercent: discountPercent,
  2849. IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()),
  2850. AccountId: accountid,
  2851. Adjustment: Number($(this).find(".hfRowTotalAdjustment").val()),
  2852. TotalAmount: Number(rowTotal),
  2853. Quantity: Number(Quantity),
  2854. ExciseAmount: 0,
  2855. RefNo: $(this).find(".refNo").val(),
  2856. DiscountGroupId: Number($(this).find("#hfProdDiscountGroupId").val()),
  2857. RefInvoiceItemId: Number(refInvoiceitemid),
  2858. MrpId: Number(MrpId),
  2859. DcItemId: Number($(this).find(".dcItemId").val()),
  2860. BatchId: 0,
  2861. IsFoc: foc,
  2862. OfferItemId: ($(this).find(".hfOfferedItemId").val() == null || $(this).find(".hfOfferedItemId").val() == undefined) ? 0 : Number($(this).find(".hfOfferedItemId").val()),
  2863. AlternateUnitId: SelectedUnitId,
  2864. DefaultSize: DefaultSize,
  2865. ParentBOMItemId: Number(ParentBOMItemId),
  2866. ConversionQuantity: Number(ConversionQuantity)
  2867. });
  2868. }
  2869. }
  2870. });
  2871. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  2872. if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $('#hfInv_IsRetun').val() == "1") {
  2873. InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId = 0;
  2874. }
  2875. invItemList.push({
  2876. InvoiceItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId),
  2877. OrderItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].orderItemId),
  2878. ItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId),
  2879. TaxGroupId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].taxGroupId),
  2880. Description: InvoiceItem.Instance().SplitedInvoiceItemList[i].description,
  2881. PriceListId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].priceListId),
  2882. UnitPrice: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice),
  2883. DiscountAmount: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountValue),
  2884. DiscountPercent: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountPercent),
  2885. IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()),
  2886. AccountId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].accountId),
  2887. Adjustment: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].Adjustment),
  2888. TotalAmount: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].TotalAmount),
  2889. Quantity: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity),
  2890. ExciseAmount: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].exciseAmount),
  2891. RefNo: InvoiceItem.Instance().SplitedInvoiceItemList[i].refNo,
  2892. DiscountGroupId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].DiscountGroupId),
  2893. RefInvoiceItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].RefInvoiceItemId),
  2894. MrpId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].MrpId) == -1 ? 0 : Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].MrpId),
  2895. DcItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].dcItemId),
  2896. BatchId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].BatchId),
  2897. IsFoc: false,
  2898. OfferItemId: 0,
  2899. });
  2900. }
  2901. $(".InvoiceItems").find(".discount-row").each(function () {
  2902. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  2903. var rowname = "discount-row";
  2904. var appliedOnWhole = false;
  2905. var totalElement = $(this).find(".netdiscount-row-total");
  2906. if (totalElement.length != 0) {
  2907. appliedOnWhole = true;
  2908. rowname = "netdiscount-row";
  2909. }
  2910. var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val();
  2911. var ItemId = $(this).find(".hfSelectedChargeId").val();
  2912. var chargeTypeId = $(this).find(".hdnChargeTypeId").val();
  2913. var ledgerId = $(this).find(".hdnChargeLedgerId").val();
  2914. var percent = $(this).find(".percentage").val();
  2915. var value = $(this).find(".fixedvalue").val();
  2916. var desc = $(this).find(".discountDesc").val();
  2917. var totalamount = $(this).find("." + rowname + "-total").html();
  2918. invItemList.push({
  2919. InvoiceItemId: $(this).find(".selectedInvoiceItemId").val() == undefined ? 0 : Number($(this).find(".selectedInvoiceItemId").val()),
  2920. OrderItemId: 0,
  2921. ItemId: Number(ItemId),
  2922. Packs: 0,
  2923. TaxGroupId: Number($(this).find(".hfProdTax").val()),
  2924. Description: $(this).find(".discountDesc").val(),
  2925. PriceListId: 0,
  2926. UnitPrice: 0,
  2927. DiscountAmount: Number($(this).find(".fixedvalue").val()),
  2928. DiscountPercent: Number($(this).find(".percentage").val()),
  2929. IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()),
  2930. AccountId: Number($(this).find(".hf_Account").val()),
  2931. RowDiscount: Number(totalamount),
  2932. SendToWallet: 0,
  2933. Adjustment: 0,
  2934. TotalAmount: 0,
  2935. Quantity: 1,
  2936. ExciseAmount: 0,
  2937. RefNo: "",
  2938. DiscountGroupId: 0,
  2939. RefInvoiceItemId: 0,
  2940. MrpId: 0,
  2941. BatchId: 0,
  2942. DcItemId: Number($(this).find(".dcItemId").val()),
  2943. IsFoc: false,
  2944. OfferItemId: 0,
  2945. });
  2946. }
  2947. });
  2948. $(".netdiscount-row").each(function () {
  2949. var rowname = "";
  2950. var appliedOnWhole = false;
  2951. var totalElement = $(this).find(".netdiscount-row-total");
  2952. if (totalElement.length != 0) {
  2953. appliedOnWhole = true;
  2954. rowname = "netdiscount-row";
  2955. }
  2956. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  2957. var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val();
  2958. var ItemId = $(this).find(".hfSelectedChargeId").val();
  2959. var chargeTypeId = $(this).find(".hdnChargeTypeId").val();
  2960. var ledgerId = $(this).find(".hdnChargeLedgerId").val();
  2961. var percent = $(this).find(".percentage").val();
  2962. var value = $(this).find(".fixedvalue").val();
  2963. var desc = $(this).find(".discountDesc").val();
  2964. var totalamount = $(this).find("." + rowname + "-total").html();
  2965. invItemList.push({
  2966. InvoiceItemId: $(this).find(".selectedInvoiceItemId").val() == undefined ? 0 : Number($(this).find(".selectedInvoiceItemId").val()),
  2967. OrderItemId: 0,
  2968. ItemId: Number(ItemId),
  2969. Packs: 0,
  2970. TaxGroupId: Number($(this).find(".hfProdTax").val()),
  2971. Description: $(this).find(".discountDesc").val(),
  2972. PriceListId: 0,
  2973. UnitPrice: 0,
  2974. DiscountAmount: Number($(this).find(".fixedvalue").val()),
  2975. DiscountPercent: Number($(this).find(".percentage").val()),
  2976. IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()),
  2977. AccountId: Number($(this).find(".hf_Account").val()),
  2978. RowDiscount: Number(totalamount),
  2979. SendToWallet: 0,
  2980. Adjustment: 0,
  2981. TotalAmount: 0,
  2982. Quantity: 1,
  2983. ExciseAmount: 0,
  2984. RefNo: "",
  2985. DiscountGroupId: 0,
  2986. RefInvoiceItemId: 0,
  2987. MrpId: 0,
  2988. BatchId: 0,
  2989. DcItemId: Number($(this).find(".dcItemId").val()),
  2990. IsFoc: false,
  2991. OfferItemId: 0,
  2992. });
  2993. }
  2994. });
  2995. $(".expense-row").each(function () {
  2996. var rowname = "";
  2997. var appliedOnWhole = false;
  2998. var totalElement = $(this).find(".expense-row-total");
  2999. if (totalElement.length != 0) {
  3000. appliedOnWhole = true;
  3001. rowname = "expense-row";
  3002. }
  3003. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  3004. var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val();
  3005. var ItemId = $(this).find(".hfSelectedChargeId").val();
  3006. var chargeTypeId = $(this).find(".hdnChargeTypeId").val();
  3007. var ledgerId = $(this).find(".hdnChargeLedgerId").val();
  3008. var percent = $(this).find(".percentage").val();
  3009. var value = $(this).find(".fixedvalue").val();
  3010. var desc = $(this).find(".discountDesc").val();
  3011. var totalamount = $(this).find("." + rowname + "-total").html();
  3012. if (Number($(this).find(".expfixedvalue").val()) != 0 || Number($(this).find(".exppercentage").val()) != 0) {
  3013. invItemList.push({
  3014. InvoiceItemId: $(this).find(".selectedInvoiceItemId").val() == undefined ? 0 : Number($(this).find(".selectedInvoiceItemId").val()),
  3015. OrderItemId: 0,
  3016. ItemId: Number(ItemId),
  3017. Packs: 0,
  3018. TaxGroupId: Number($(this).find(".hfProdTax").val()),
  3019. Description: $(this).find(".expenseDesc").val(),
  3020. PriceListId: 0,
  3021. UnitPrice: 0,
  3022. DiscountAmount: -Number($(this).find(".expfixedvalue").val()),
  3023. DiscountPercent: -Number($(this).find(".exppercentage").val()),
  3024. IsTaxInclusive: Boolean($('.dropdown_istaxinclusive').val()),
  3025. AccountId: Number($(this).find(".hf_Account").val()),
  3026. RowDiscount: -Number(totalamount),
  3027. SendToWallet: 0,
  3028. Adjustment: 0,
  3029. TotalAmount: 0,
  3030. Quantity: 1,
  3031. ExciseAmount: 0,
  3032. RefNo: "",
  3033. DiscountGroupId: 0,
  3034. RefInvoiceItemId: 0,
  3035. MrpId: 0,
  3036. BatchId: 0,
  3037. DcItemId: Number($(this).find(".dcItemId").val()),
  3038. IsFoc: false,
  3039. OfferItemId: 0,
  3040. });
  3041. }
  3042. }
  3043. });
  3044. return invItemList;
  3045. }
  3046. getCharges() {
  3047. var ChargeList = new Array();
  3048. var chargeIndex = 0;
  3049. InvoiceItem.Instance().update_discount_total();
  3050. InvoiceItem.Instance().update_expense_total();
  3051. $(".discount-row,.netdiscount-row").each(function () {
  3052. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  3053. var rowname = "discount-row";
  3054. var appliedOnWhole = false;
  3055. var totalElement = $(this).find(".netdiscount-row-total");
  3056. if (totalElement.length != 0) {
  3057. appliedOnWhole = true;
  3058. rowname = "netdiscount-row";
  3059. }
  3060. if ($(this).find(".hfSelectedChargeId").val() != "" && $(this).find(".hfSelectedChargeId").val() != "0") {
  3061. var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val();
  3062. chargeIndex += 1;
  3063. var ChargeId = $(this).find(".hfSelectedChargeId").val();
  3064. var chargeTypeId = $(this).find(".hdnChargeTypeId").val();
  3065. var ledgerId = $(this).find(".hf_Account").val();
  3066. var percent = $(this).find(".percentage").val();
  3067. var value = $(this).find(".fixedvalue").val();
  3068. var desc = $(this).find(".discountDesc").val();
  3069. var totalamount = $(this).find("." + rowname + "-total").html();
  3070. ChargeList.push({
  3071. InvoiceChargeId: Number(invoicechargeid),
  3072. ChargeId: Number(ChargeId),
  3073. ChargeTypeId: Number(chargeTypeId),
  3074. ChargeIndex: chargeIndex,
  3075. Percentage: Number(percent),
  3076. FixedAmount: Number(value),
  3077. ApplyWhole: appliedOnWhole,
  3078. Description: desc,
  3079. TotalAmount: Number(totalamount),
  3080. LedgerId: Number(ledgerId),
  3081. TaxGroupId: Number($(this).find(".hfProdTax").val())
  3082. });
  3083. }
  3084. }
  3085. });
  3086. $(".expense-row").each(function () {
  3087. if ($(this).find(".selectedItemId").val() != undefined) {
  3088. if ($(this).find(".hfSelectedChargeId").val() != "" && $(this).find(".hfSelectedChargeId").val() != "0") {
  3089. var invoicechargeid = $(this).find(".selectedInvoiceChargeId").val();
  3090. let ChargeId = $(this).find(".hfSelectedChargeId").val();
  3091. var chargeTypeId = $(this).find(".hdnChargeTypeId").val();
  3092. var percent = $(this).find(".exppercentage").val();
  3093. var value = $(this).find(".expfixedvalue").val();
  3094. var desc = $(this).find(".expenseDesc").val();
  3095. var totalamount = $(this).find(".expense-row-total").html();
  3096. var ledgerId = $(this).find(".hf_Account").val();
  3097. if (Number(value) != 0 || Number(percent)) {
  3098. ChargeList.push({
  3099. InvoiceChargeId: Number(invoicechargeid),
  3100. ChargeId: Number(ChargeId),
  3101. ChargeTypeId: Number(chargeTypeId),
  3102. Percentage: Number(percent),
  3103. FixedAmount: Number(value),
  3104. ApplyWhole: true,
  3105. Description: desc,
  3106. TotalAmount: Number(totalamount),
  3107. LedgerId: Number(ledgerId),
  3108. TaxGroupId: Number($(this).find(".hfProdTax").val())
  3109. });
  3110. }
  3111. }
  3112. }
  3113. });
  3114. return ChargeList;
  3115. }
  3116. getobj() {
  3117. var item = Number($(".selectedItemId").val());
  3118. var inventorytypeid = 0;
  3119. var AdjustmentAccountId = 0;
  3120. var isqtyavail = true;
  3121. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () {
  3122. Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItem(item).then(function (response) {
  3123. inventorytypeid = response.result.InventoryTypeId;
  3124. $(".InvoiceItems").find(".remove_item").remove();
  3125. InvoiceItem.Instance().update_total();
  3126. InvoiceItem.Instance().TotalAdjustment();
  3127. if ($("#chk_tcsapplied").prop("checked") == true && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && InvoiceItem.Instance().EnableTenantTcs == false) {
  3128. MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3129. $(".InvoiceItems").append("<div class='item-row added-row InvoiceitemRow-0'></div>");
  3130. return false;
  3131. }
  3132. var CompanyName = $(".txtAutoComplete_orgcontactid").text();
  3133. if (CompanyName == "") {
  3134. $(".hfAutoCompleteId_orgcontactid").val(0);
  3135. }
  3136. var Adjustment = $('#txt_Adjustment').val();
  3137. if ($('#chk_AutoAdjustment').is(':checked')) {
  3138. if ($('#hf_AdjustmentAccountId').val() == 0) {
  3139. MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3140. return false;
  3141. }
  3142. InvoiceItem.Instance().TotalAdjustment();
  3143. Adjustment = $('#txt_Adjustment').val();
  3144. AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val());
  3145. }
  3146. });
  3147. });
  3148. if ($('#chk_AutoAdjustment').is(':checked')) {
  3149. if ($('#hf_AdjustmentAccountId').val() == 0) {
  3150. MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3151. return false;
  3152. }
  3153. else
  3154. AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val());
  3155. }
  3156. let isemptyrow = false;
  3157. let rownotexist = true;
  3158. let itemarray = [];
  3159. let emptysplitrow = false;
  3160. let itemname = "";
  3161. var IsUnitPriceZero = false;
  3162. $(".InvoiceItems").find(".item-addedrow").each(function () {
  3163. rownotexist = false;
  3164. if (!$(this).hasClass('SplitItem')) {
  3165. if ($(this).find(".selectedItemId").val() == undefined || $(this).find(".selectedItemId").val() == 0) {
  3166. isemptyrow = true;
  3167. }
  3168. if ($(this).find(".hfProdTax").val() == "0" || $(this).find(".hf_Account").val() == "0") {
  3169. itemarray.push($(this));
  3170. }
  3171. if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && (InvoiceItem.Instance().AutoDc == true || InvoiceItem.Instance().OrderSettingId == 2)) {
  3172. inventorytypeid = Number($(this).find("#inventorytypeid").val());
  3173. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  3174. if ((Number($(this).find('.prodQuantity').val()) > Number($(this).find('.prodAvail').text())) && $(".hdn_invoiceid").val() == "0" && inventorytypeid != 2) {
  3175. isqtyavail = false;
  3176. }
  3177. else {
  3178. let Qty = Number($(this).find('.prodQuantity').val());
  3179. let AvQty = Number($(this).find('.prodAvail').text()) + Number($(this).find('.Qty').val());
  3180. if (Qty > AvQty && inventorytypeid != 2)
  3181. isqtyavail = false;
  3182. }
  3183. }
  3184. }
  3185. }
  3186. else {
  3187. if (InvoiceItem.Instance().SplitedInvoiceItemList.find(x => x.itemId == Number($(this).find(".selectedItemId").val()))) {
  3188. }
  3189. else {
  3190. emptysplitrow = true;
  3191. itemname = $(this).find(".prodName").text();
  3192. }
  3193. }
  3194. var UnitPrice = Number($(this).find(".prodPrice").val());
  3195. if (UnitPrice == 0 && $(this).find(".hf_IsBOM").val() == "false" && $(this).find(".hf_IsFoc").val() == "false") {
  3196. IsUnitPriceZero = true;
  3197. }
  3198. });
  3199. if (!isqtyavail) {
  3200. MessageHelper.Instance().showError("Please check available quantity", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3201. return false;
  3202. }
  3203. if (isemptyrow) {
  3204. MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3205. return false;
  3206. }
  3207. if (rownotexist) {
  3208. MessageHelper.Instance().showError("Please Add Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3209. return false;
  3210. }
  3211. if (emptysplitrow) {
  3212. MessageHelper.Instance().showError("Please Select Mrp/Batch for the Item: " + itemname, $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3213. return false;
  3214. }
  3215. let couponitemrow = false;
  3216. $(".addednetdiscount-row").each(function () {
  3217. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  3218. if (($(this).find(".percentage").val() == "0" || $(this).find(".percentage").val() == "") && ($(this).find(".fixedvalue").val() == 0 || $(this).find(".fixedvalue").val() == ""))
  3219. isemptyrow = true;
  3220. }
  3221. if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined)
  3222. couponitemrow = true;
  3223. });
  3224. if (isemptyrow) {
  3225. MessageHelper.Instance().showError("Please enter percentage or value for coupon item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3226. return false;
  3227. }
  3228. let expenseitemrow = false;
  3229. $(".addedexpense-row").each(function () {
  3230. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  3231. if (($(this).find(".exppercentage").val() == "0" || $(this).find(".exppercentage").val() == "") && ($(this).find(".expfixedvalue").val() == 0 || $(this).find(".expfixedvalue").val() == ""))
  3232. isemptyrow = true;
  3233. }
  3234. if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined)
  3235. expenseitemrow = true;
  3236. });
  3237. if (isemptyrow) {
  3238. MessageHelper.Instance().showError("Please enter percentage or value for Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3239. return false;
  3240. }
  3241. if (IsUnitPriceZero) {
  3242. MessageHelper.Instance().showError("Item UnitPrice should not be zero.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3243. return false;
  3244. }
  3245. if (couponitemrow) {
  3246. MessageHelper.Instance().showError("Please Select Coupon Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3247. return false;
  3248. }
  3249. if (expenseitemrow) {
  3250. MessageHelper.Instance().showError("Please Select Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3251. return false;
  3252. }
  3253. var wallets = InvoiceItem.Instance().getwalletinvoiceditems();
  3254. var invItems = InvoiceItem.Instance().getInvoiceItems();
  3255. if (invItems.length == 0) {
  3256. MessageHelper.Instance().showError("You Should Add atleast One Item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3257. return false;
  3258. }
  3259. else {
  3260. var qtyresult = invItems.find(x => x.AccountId == 0) ? true : false;
  3261. if (qtyresult == true) {
  3262. for (var i = 0; i < itemarray.length; i++) {
  3263. itemarray[i].find(".div_MoreDetails").removeClass("hidden");
  3264. }
  3265. MessageHelper.Instance().showError("Account Not Configured for the item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3266. return false;
  3267. }
  3268. var qty = invItems.find(x => x.Quantity == 0) ? true : false;
  3269. if (qty == true) {
  3270. MessageHelper.Instance().showError("Item quantity should not be zero.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3271. return false;
  3272. }
  3273. var TaxGroup = invItems.find(x => x.TaxGroupId == 0) ? true : false;
  3274. if (TaxGroup == true) {
  3275. for (var i = 0; i < itemarray.length; i++) {
  3276. itemarray[i].find(".div_MoreDetails").removeClass("hidden");
  3277. }
  3278. MessageHelper.Instance().showError("TaxGroup Not Configured for the item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3279. return false;
  3280. }
  3281. }
  3282. var billingAddressId = $(".hfAutoCompleteId_billtoaddressid").val();
  3283. if (billingAddressId == null)
  3284. billingAddressId = $("#hfId_billtoaddressid").val();
  3285. var invoiceid = $(".hdn_invoiceid").val();
  3286. let refInvoiceId = 0;
  3287. if ($(".hdn_refinvoiceid").val() != undefined && Number($(".hdn_refinvoiceid").val()) != 0)
  3288. refInvoiceId = Number($(".hdn_refinvoiceid").val());
  3289. if (invoiceid == undefined)
  3290. invoiceid = 0;
  3291. if (($(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "3") && $("#hf_AppSettingName").val() == "Create Return") {
  3292. invoiceid = 0;
  3293. if (refInvoiceId == 0) {
  3294. refInvoiceId = Number($(".hdn_invoiceid").val());
  3295. $(".hdn_refinvoiceid").val($(".hdn_invoiceid").val());
  3296. }
  3297. $(".hdn_invoiceid").val("0");
  3298. $(".hdn_journalno").val("0");
  3299. }
  3300. let orgcontactid = $(".txtAutoComplete_orgcontactid").val();
  3301. var dcid = InvoiceItem.Instance().dcid;
  3302. if (invoiceid == 0 && ($(".hdn_invoicetypeid").val() == '3' || $(".hdn_invoicetypeid").val() == '4' || $(".hdn_invoicetypeid").val() == '7' || $(".hdn_invoicetypeid").val() == '6')) {
  3303. dcid = 0;
  3304. }
  3305. var orderid = InvoiceItem.Instance().orderid;
  3306. if (orderid == undefined || orderid == 0) {
  3307. orderid = 0;
  3308. }
  3309. var ClaimId = InvoiceItem.Instance().ClaimId;
  3310. if (ClaimId == undefined || ClaimId == 0) {
  3311. ClaimId = 0;
  3312. }
  3313. else
  3314. orderid = ClaimId;
  3315. var branchid = 0;
  3316. $(".txt_RefNo").val() == "null" ? $(".txt_RefNo").val("") : $(".txt_refno").val();
  3317. var description = $(".divCustomProperties_systemnotes").find("textarea").val();
  3318. if ($('.txt_tcsadjustment').val() == "")
  3319. $('.txt_tcsadjustment').val(0);
  3320. if (Number($(".nettotal").html()) < 0) {
  3321. MessageHelper.Instance().showError("Invoice value should not be less than 0", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3322. return false;
  3323. }
  3324. var InvoiceObject = {
  3325. TotalAmount: Number($(".nettotal").html()),
  3326. InvoiceItems: invItems,
  3327. InvoiceCharges: InvoiceItem.Instance().getCharges(),
  3328. AutoAdjustment: Boolean($('#chk_AutoAdjustment').is(':checked')),
  3329. AutoDc: InvoiceItem.Instance().AutoDc,
  3330. InvItemTaxAdjustments: InvoiceItem.Instance().invItemTaxAdjustmentList,
  3331. JournalAlloc: wallets,
  3332. AdjustmentAccountId: Number($("#txt_AdjustmentAccountName").val()),
  3333. InvoiceId: Number(invoiceid),
  3334. RefInvoiceId: Number(refInvoiceId),
  3335. OrgContactId: Number(orgcontactid),
  3336. DeletedInvoiceId: InvoiceItem.Instance().deleted_invoiceItems,
  3337. IsOfferChargeApplied: InvoiceItem.Instance().isOfferChargeApplied,
  3338. };
  3339. return InvoiceObject;
  3340. }
  3341. saveInvoice() {
  3342. $(".InvoiceItems").find(".remove_item").remove();
  3343. InvoiceItem.Instance().update_total();
  3344. InvoiceItem.Instance().TotalAdjustment();
  3345. var inventorytypeid = 0;
  3346. var AdjustmentAccountId = 0;
  3347. var item = Number($(".selectedItemId").val());
  3348. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () {
  3349. Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItem(item).then(function (response) {
  3350. inventorytypeid = response.result.InventoryTypeId;
  3351. if ($("#chk_tcsapplied").prop("checked") == true && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && InvoiceItem.Instance().EnableTenantTcs == false) {
  3352. MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3353. $(".InvoiceItems").append("<div class='item-row added-row InvoiceitemRow-0'></div>");
  3354. return false;
  3355. }
  3356. var CompanyName = $(".txtAutoComplete_orgcontactid").text();
  3357. if (CompanyName == "") {
  3358. $(".hfAutoCompleteId_orgcontactid").val(0);
  3359. }
  3360. if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && (InvoiceItem.Instance().AutoDc == true || InvoiceItem.Instance().OrderSettingId == 2)) {
  3361. var isqtyavail = true;
  3362. $(".InvoiceItems").find(".item-addedrow").each(function () {
  3363. if (!$(this).hasClass('SplitItem')) {
  3364. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  3365. if (Number($(this).find('.prodQuantity').val()) > Number($(this).find('.prodAvail').text()) && inventorytypeid != 2) {
  3366. isqtyavail = false;
  3367. }
  3368. }
  3369. }
  3370. });
  3371. if (!isqtyavail) {
  3372. MessageHelper.Instance().showError("Please check available quantity", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3373. return false;
  3374. }
  3375. }
  3376. });
  3377. });
  3378. var Adjustment = $('#txt_Adjustment').val();
  3379. var AdjustmentAccountId = 0;
  3380. if ($('#chk_AutoAdjustment').is(':checked')) {
  3381. if ($('#hf_AdjustmentAccountId').val() == 0) {
  3382. MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3383. return false;
  3384. }
  3385. InvoiceItem.Instance().TotalAdjustment();
  3386. Adjustment = $('#txt_Adjustment').val();
  3387. AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val());
  3388. }
  3389. if (Number($('#txt_Adjustment').val()) != 0) {
  3390. if ($('#hf_AdjustmentAccountId').val() == 0) {
  3391. MessageHelper.Instance().showError("Please Select Adjustment Account", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3392. return false;
  3393. }
  3394. else
  3395. AdjustmentAccountId = Number($("#txt_AdjustmentAccountName").val());
  3396. }
  3397. let isemptyrow = false;
  3398. let rownotexist = true;
  3399. let itemarray = [];
  3400. let emptysplitrow = false;
  3401. let itemname = "";
  3402. $(".InvoiceItems").find(".item-addedrow").each(function () {
  3403. rownotexist = false;
  3404. if (!$(this).hasClass('SplitItem')) {
  3405. if ($(this).find(".selectedItemId").val() == undefined || $(this).find(".selectedItemId").val() == 0) {
  3406. isemptyrow = true;
  3407. }
  3408. if ($(this).find(".hfProdTax").val() == "0" || $(this).find(".hf_Account").val() == "0") {
  3409. itemarray.push($(this));
  3410. }
  3411. }
  3412. else {
  3413. if (InvoiceItem.Instance().SplitedInvoiceItemList.find(x => x.itemId == Number($(this).find(".selectedItemId").val()))) {
  3414. }
  3415. else {
  3416. emptysplitrow = true;
  3417. itemname = $(this).find(".prodName").text();
  3418. }
  3419. }
  3420. });
  3421. if (isemptyrow) {
  3422. MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3423. return false;
  3424. }
  3425. if (rownotexist) {
  3426. MessageHelper.Instance().showError("Please Add Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3427. return false;
  3428. }
  3429. if (emptysplitrow) {
  3430. MessageHelper.Instance().showError("Please Select Mrp/Batch for the Item: " + itemname, $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3431. return false;
  3432. }
  3433. let couponitemrow = false;
  3434. $(".addednetdiscount-row").each(function () {
  3435. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  3436. if (($(this).find(".percentage").val() == "0" || $(this).find(".percentage").val() == "") && ($(this).find(".fixedvalue").val() == 0 || $(this).find(".fixedvalue").val() == ""))
  3437. isemptyrow = true;
  3438. }
  3439. if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined)
  3440. couponitemrow = true;
  3441. });
  3442. if (isemptyrow) {
  3443. MessageHelper.Instance().showError("Please enter percentage or value for coupon item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3444. return false;
  3445. }
  3446. if (couponitemrow) {
  3447. MessageHelper.Instance().showError("Please Select Coupon Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3448. return false;
  3449. }
  3450. let expenseitemrow = false;
  3451. $(".addedexpense-row").each(function () {
  3452. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  3453. if (($(this).find(".exppercentage").val() == "0" || $(this).find(".exppercentage").val() == "") && ($(this).find(".expfixedvalue").val() == 0 || $(this).find(".expfixedvalue").val() == ""))
  3454. isemptyrow = true;
  3455. }
  3456. if ($(this).find(".selectedItemId").val() == "0" || $(this).find(".selectedItemId").val() == undefined)
  3457. expenseitemrow = true;
  3458. });
  3459. if (isemptyrow) {
  3460. MessageHelper.Instance().showError("Please enter percentage or value for Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3461. return false;
  3462. }
  3463. if (expenseitemrow) {
  3464. MessageHelper.Instance().showError("Please Select Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3465. return false;
  3466. }
  3467. var wallets = InvoiceItem.Instance().getwalletinvoiceditems();
  3468. var invItems = InvoiceItem.Instance().getInvoiceItems();
  3469. if (invItems.length == 0) {
  3470. MessageHelper.Instance().showError("You Should Add atleast One Item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3471. return false;
  3472. }
  3473. else {
  3474. var qtyresult = invItems.find(x => x.AccountId == 0) ? true : false;
  3475. if (qtyresult == true) {
  3476. for (var i = 0; i < itemarray.length; i++) {
  3477. itemarray[i].find(".div_MoreDetails").removeClass("hidden");
  3478. }
  3479. MessageHelper.Instance().showError("Account Not Configured for the item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3480. return false;
  3481. }
  3482. var qty = invItems.find(x => x.Quantity == 0) ? true : false;
  3483. if (qty == true) {
  3484. MessageHelper.Instance().showError("Item quantity should not be zero.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3485. return false;
  3486. }
  3487. var TaxGroup = invItems.find(x => x.TaxGroupId == 0) ? true : false;
  3488. if (TaxGroup == true) {
  3489. for (var i = 0; i < itemarray.length; i++) {
  3490. itemarray[i].find(".div_MoreDetails").removeClass("hidden");
  3491. }
  3492. MessageHelper.Instance().showError("TaxGroup Not Configured for the item.", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3493. return false;
  3494. }
  3495. }
  3496. var PaymentTermName = $(".txtAutoComplete_paymentiermid").text();
  3497. var billingAddressId = $(".hfAutoCompleteId_billtoaddressid").val();
  3498. if (billingAddressId == null)
  3499. billingAddressId = $("#hfId_billtoaddressid").val();
  3500. var invoiceid = $(".hdn_invoiceid").val();
  3501. let refInvoiceId = 0;
  3502. if (invoiceid == undefined)
  3503. invoiceid = 0;
  3504. if (($(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "3") && $("#hf_AppSettingName").val() == "Create Return") {
  3505. invoiceid = 0;
  3506. refInvoiceId = Number($(".hdn_invoiceid").val());
  3507. $(".hdn_refinvoiceid").val($(".hdn_invoiceid").val());
  3508. $(".hdn_invoiceid").val("0");
  3509. $(".hdn_journalno").val("0");
  3510. }
  3511. let orgcontactid = $(".txtAutoComplete_orgcontactid").val();
  3512. var dcid = InvoiceItem.Instance().dcid;
  3513. if (invoiceid == 0 && ($(".hdn_invoicetypeid").val() == '3' || $(".hdn_invoicetypeid").val() == '4' || $(".hdn_invoicetypeid").val() == '7' || $(".hdn_invoicetypeid").val() == '6')) {
  3514. dcid = 0;
  3515. }
  3516. var orderid = InvoiceItem.Instance().orderid;
  3517. if (orderid == undefined || orderid == 0) {
  3518. orderid = 0;
  3519. }
  3520. var ClaimId = InvoiceItem.Instance().ClaimId;
  3521. if (ClaimId == undefined || ClaimId == 0) {
  3522. ClaimId = 0;
  3523. }
  3524. else
  3525. orderid = ClaimId;
  3526. var branchid = 0;
  3527. if ((ClaimId != 0 || orderid != 0) && InvoiceItem.Instance().dcid == 0)
  3528. for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
  3529. if (obj.Key === "hf_" + $("#hfLayout_InstalledPageId").val() + "_branchid")
  3530. branchid = InvoiceItem.Instance().orderid = Number(obj.Value);
  3531. }
  3532. else
  3533. branchid = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid"));
  3534. $(".txt_RefNo").val() == "null" ? $(".txt_RefNo").val("") : $(".txt_refno").val();
  3535. var description = $(".divCustomProperties_systemnotes").find("textarea").val();
  3536. if ($('.txt_tcsadjustment').val() == "")
  3537. $('.txt_tcsadjustment').val(0);
  3538. var InvoiceObject = {
  3539. PaymentTermName: PaymentTermName,
  3540. BranchId: branchid,
  3541. TotalAmount: Number($(".nettotal").html()),
  3542. InvoiceItems: invItems,
  3543. InvoiceCharges: InvoiceItem.Instance().getCharges(),
  3544. AutoAdjustment: Boolean($('#chk_AutoAdjustment').is(':checked')),
  3545. AutoDc: InvoiceItem.Instance().AutoDc,
  3546. InvItemTaxAdjustments: InvoiceItem.Instance().invItemTaxAdjustmentList,
  3547. JournalAlloc: wallets,
  3548. AdjustmentAccountId: Number($("#txt_AdjustmentAccountName").val()),
  3549. InvoiceId: Number(invoiceid),
  3550. RefInvoiceId: Number(refInvoiceId),
  3551. OrgContactid: orgcontactid,
  3552. DeletedInvoiceId: InvoiceItem.Instance().deleted_invoiceItems,
  3553. IsOfferChargeApplied: InvoiceItem.Instance().isOfferChargeApplied,
  3554. };
  3555. return InvoiceObject;
  3556. }
  3557. addRow() {
  3558. let isemptyrow = false;
  3559. $(".InvoiceItems").find(".item-addedrow").each(function () {
  3560. if (!$(this).hasClass('SplitItem')) {
  3561. if ($(this).find(".selectedItemId").val() == undefined || $(this).find(".selectedItemId").val() == 0) {
  3562. isemptyrow = true;
  3563. }
  3564. }
  3565. });
  3566. if (isemptyrow) {
  3567. MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  3568. return false;
  3569. }
  3570. var emptyRow = {
  3571. orderItemId: 0,
  3572. invoiceItemId: 0,
  3573. itemName: "",
  3574. itemId: 0,
  3575. itemSKU: "",
  3576. unitName: "",
  3577. packSize: 0,
  3578. packCount: 0,
  3579. packs: 0,
  3580. quantity: 0,
  3581. availPacks: 0,
  3582. availQty: 0,
  3583. listPrice: 0,
  3584. description: "",
  3585. taxGroupName: "",
  3586. taxGroupId: 0,
  3587. isTaxInclusive: $("#hf_istaxinclusive").val(),
  3588. addlDiscountPercent: 0,
  3589. addlDiscountValue: 0,
  3590. creditNote: 0,
  3591. priceListId: 0,
  3592. batchId: 0,
  3593. unitPrice: 0,
  3594. invoiceallocations: null,
  3595. exciseInvoiceItem: null,
  3596. accountId: 0,
  3597. accountName: "",
  3598. walletId: 0,
  3599. Adjustment: 0,
  3600. IsFoc: false,
  3601. TariffNo: "",
  3602. exciseAmount: 0,
  3603. discountName: "",
  3604. discountId: 0,
  3605. refNo: "",
  3606. DiscountGroupId: 0,
  3607. DiscountGroupName: '',
  3608. RefInvoiceItemId: 0,
  3609. MrpId: 0,
  3610. taxAdjustment: 0,
  3611. assesableAdjustment: 0,
  3612. inventoryTypeId: 0,
  3613. dcItemId: 0,
  3614. TotalRowAmount: 0,
  3615. maxQty: 0,
  3616. OfferItemId: 0
  3617. };
  3618. InvoiceItem.instance.addDataRow(emptyRow, false);
  3619. }
  3620. addDataRow(row, IsSplitItem) {
  3621. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("tenants/themes/compact/components/details/details.js", function () {
  3622. });
  3623. this.rowIndex = $(".InvoiceItems").find(".item-addedrow").length + 1;
  3624. var bg = "";
  3625. if (row.packSize == 0)
  3626. row.packSize = 1;
  3627. if (row.packCount == 0)
  3628. row.packCount = 1;
  3629. if (row.quantity == 0)
  3630. row.quantity = row.packCount * row.packs * row.packSize;
  3631. var price = row.unitPrice;
  3632. if (row.unitPrice == 0)
  3633. price = row.listPrice;
  3634. var currenttaxgroupid = 0;
  3635. if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $('#hfInv_IsRetun').val() == "1") {
  3636. row.invoiceallocations = null;
  3637. row.invoiceItemId = 0;
  3638. }
  3639. if ($('#hfInv_IsRetun').val() == "1")
  3640. row.invoiceItemId = 0;
  3641. var zeroBilled = "";
  3642. if (price == 0)
  3643. zeroBilled = "bg-danger";
  3644. var zeroQtyText = "";
  3645. var zeroQtyDiv = "bg-light";
  3646. let invoiceid = $(".hdn_invoiceid").val();
  3647. if (invoiceid == "0") {
  3648. if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && row.itemId != 0 && row.IsFoc == false) {
  3649. if (row.availQty == 0) {
  3650. row.quantity = 0;
  3651. zeroQtyText = "text-danger";
  3652. zeroQtyDiv = "bg-danger";
  3653. }
  3654. else if (row.availQty < row.quantity) {
  3655. row.quantity = row.availQty;
  3656. }
  3657. }
  3658. }
  3659. var readonlyQty = "";
  3660. var ManageInvoice = 2;
  3661. var AutoDc = false;
  3662. var ManageInvoiceTax = 2;
  3663. var readonlyPrice = "";
  3664. var readonlyDisc = "";
  3665. var readonlyTax = "";
  3666. if (ManageInvoice == 1 && AutoDc == false) {
  3667. readonlyQty = "readonly";
  3668. readonlyPrice = "readonly";
  3669. readonlyDisc = "readonly";
  3670. readonlyTax = "disabled";
  3671. }
  3672. if ($('.hdn_invoicetypeid').val() == "1" && ManageInvoiceTax == 1 && AutoDc == false) {
  3673. readonlyTax = "readonly";
  3674. }
  3675. if (row.inventoryTypeId == "2") {
  3676. readonlyQty = "";
  3677. readonlyPrice = "";
  3678. }
  3679. var activeDiscVal = "";
  3680. var activeDiscPercent = "";
  3681. var activeDiscMul = "";
  3682. var activeDiscText = "";
  3683. var discValue = 0;
  3684. if (row.addlDiscountPercent > 0) {
  3685. discValue = row.addlDiscountPercent;
  3686. activeDiscPercent = "active";
  3687. activeDiscText = "%";
  3688. }
  3689. else if (row.addlDiscountValue > 0 && row.DiscountGroupId > 0) {
  3690. discValue = row.addlDiscountValue;
  3691. activeDiscMul = "active";
  3692. activeDiscText = "Mul";
  3693. }
  3694. else {
  3695. discValue = row.addlDiscountValue;
  3696. activeDiscVal = "active";
  3697. activeDiscText = "Val";
  3698. }
  3699. var itemNameClass = "floating-label-form-group";
  3700. if (row.invoiceItemId != 0)
  3701. itemNameClass = "";
  3702. var mt = "";
  3703. if (row.invoiceItemId != 0) {
  3704. mt = "mt-5";
  3705. }
  3706. if (row.orderItemId != 0) {
  3707. mt = "mt-10";
  3708. }
  3709. let AlternateUnitId = row.AlternateUnitId;
  3710. let DefaultSize = row.DefaultSize;
  3711. if (AlternateUnitId == undefined) {
  3712. AlternateUnitId = 0;
  3713. }
  3714. if (row.ParentBOMItemId == null)
  3715. row.ParentBOMItemId = 0;
  3716. if (row.inventoryTypeId != 5 && row.inventoryTypeId != 6 && row.inventoryTypeId != 7) {
  3717. var IsBom = "";
  3718. if (row.IsBoMItem == true && row.IsBoMItem != undefined) {
  3719. IsBom = "hidden";
  3720. }
  3721. var isbomitem = false;
  3722. if (row.ParentBOMItemId != 0)
  3723. isbomitem = true;
  3724. var html = '<div id="div_itemAddedRow_' + this.rowIndex + '" class="item-row item-addedrow ' + bg + '">' +
  3725. '<div class="row mx-0 justify-content-between align-items-end ' + IsBom + ' divItemRow_' + row.itemId + ' ">' +
  3726. '<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>' +
  3727. '<div class=" item-name min-padding" style="margin-left:20px;">' +
  3728. '<lable for="lbl_itemname" class="d-md-none">Item Name</lable>' +
  3729. '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
  3730. '<input type="hidden" class="orderItemId" value="' + row.orderItemId + '" />' +
  3731. '<input type="hidden" class="dcItemId" value="' + row.dcItemId + '" />' +
  3732. '<input type="hidden" class="selectedInvoiceItemId" value="' + row.invoiceItemId + '" />' +
  3733. '<input type="hidden" class="refInvoiceItemId" value="' + row.RefInvoiceItemId + '" />' +
  3734. '<input type="hidden" class="selectedItemId" id="hf_txtitem_' + this.rowIndex + '" value="' + row.itemId + '" />' +
  3735. '<input type="hidden" id="selectedItemId" value="' + row.itemId + '" />' +
  3736. '<input type="hidden" id="inventorytypeid" value="' + row.itemId + '" />' +
  3737. '<input type="hidden" class="selectedItemName" value="' + row.itemname + '" />' +
  3738. '<input type="hidden" class="hfMrpId" value="' + row.MrpId + '" />' +
  3739. '<input type="hidden" class="offerapplied" value="0" />' +
  3740. '<input type="hidden" class="refNo" value="' + row.refNo + '"/>' +
  3741. '<input type="hidden" class="description" value="' + row.description + '"/>' +
  3742. '<input type="hidden" class="IsExchangeItem" value="' + row.ExchangeItem + '" />' +
  3743. '<input type="hidden" class="maxQty" value="' + row.maxQty + '" />' +
  3744. '<input type="hidden" class="Qty" value="' + row.quantity + '" />' +
  3745. '<input type="hidden" class="hfAccountId" value="' + row.accountId + '"/>' +
  3746. '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="' + row.taxAdjustment + '" />' +
  3747. '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="' + row.assesableAdjustment + '" />' +
  3748. '<input type="hidden" class="hfoldItemId" value="' + row.itemId + '"/>' +
  3749. '<input type="hidden" class="hf_IsFoc" value="' + row.IsFoc + '"/>' +
  3750. '<input type="hidden" class="hf_UnitPrice" value="' + price + '"/>' +
  3751. '<input type="hidden" class="hf_AlternateUnitId" value="' + AlternateUnitId + '"/>' +
  3752. '<input type="hidden" class="hf_AlternateUnitName" value="' + row.AlternateUnitName + '"/>' +
  3753. '<input type="hidden" class="hf_UnitName" value="' + row.unitName + '"/>' +
  3754. '<input type="hidden" class="hf_DefaultSize" value="' + DefaultSize + '"/>' +
  3755. '<input type="hidden" class="hf_IsBOM" value="' + isbomitem + '"/>' +
  3756. '<input type="hidden" class="hf_ParentBOMItemId" value="' + row.ParentBOMItemId + '"/>' +
  3757. '<input type="hidden" class="hf_IsMultipleUOM" value="' + row.IsMultipleUOMs + '"/>' +
  3758. '<input type="hidden" class="hf_IsManualUOM" value="' + row.IsManualUOM + '"/>' +
  3759. '<input type="hidden" class="hf_ConversionQuantity" value="' + row.ConversionQuantity + '"/>' +
  3760. '<input type="hidden" class="hf_IsSpecialPrice" value="' + row.IsSpecialPrice + '"/>' +
  3761. '<input type="hidden" class="hf_AddtionalDiscount" value="0"/>';
  3762. if (row.IsFoc == true) {
  3763. html += '<input type="hidden" class="hfOfferedItemId" value="' + row.OfferItemId + '"/>';
  3764. }
  3765. html += '<div class="item-name-wrap">' +
  3766. '<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>';
  3767. if (row.invoiceItemId != 0) {
  3768. var itemName = row.itemSKU + ' - ' + row.itemName;
  3769. if (row.ExchangeItem)
  3770. itemName = '(Exchange) ' + row.itemSKU + ' - ' + row.itemName;
  3771. html += '<a class="default prodName-link mt-10 ItemName" href="javascript:;">' + itemName + '</a>';
  3772. }
  3773. else {
  3774. var itemName = "";
  3775. if (row.ExchangeItem)
  3776. itemName = '(Exchange) ' + row.itemName;
  3777. else if (row.itemName != "" && row.itemSKU != "") {
  3778. itemName = row.itemSKU + '-' + row.itemName;
  3779. html += '<a class="default prodName-link mt-10 ItemName" href="javascript:;">' + itemName + '</a>';
  3780. }
  3781. else if (row.itemName != "") {
  3782. itemName = row.itemName;
  3783. html += '<a class="default prodName-link mt-10 ItemName" href="javascript:;">' + itemName + '</a>';
  3784. }
  3785. else {
  3786. html += '<select class="form-control prodName" value="" id="txt_item_' + this.rowIndex + '" placeholder=" Select the item to Invoice" style="width:100%;" id="txtItem"></select>';
  3787. }
  3788. }
  3789. html += '</div>' +
  3790. '</div></div>' +
  3791. '<div class="col-lg-2 col-md-6 pr-0 my-15">' +
  3792. '<div class="floating-label-form-group text-center border-left-0">' +
  3793. '<lable for="lbl_qty" class="d-md-none">Qty</lable>' +
  3794. '<input type="text" class="prodQuantity text-center ' + zeroQtyText + ' form-control" placeholder="0.00" inputmode="numeric" value="' + row.quantity + '" ' + readonlyQty + ' />' +
  3795. '</div>' +
  3796. '</div>' +
  3797. '<div class="col-lg-2 col-md-4 div_UnitPrice my-15">' +
  3798. '<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>';
  3799. var readonly = "";
  3800. html += '<input type="text" class="prodPrice text-center form-control" placeholder="0.00" inputmode="numeric" value="' + price + '" ' + readonlyPrice + ' />';
  3801. html += '</div></div>' +
  3802. '<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>' +
  3803. '<div class="col-lg-2 col-md-4 my-15 div_Discount"> ' +
  3804. '<div class="floating-label-form-group text-center">' +
  3805. '<lable for="lbl_disc" class="d-md-none">Disc.</lable>' +
  3806. '<input type="hidden" id="hfProdDiscountGroupId" value="' + row.DiscountGroupId + '" />' +
  3807. '<input type="hidden" id="hfProdDiscountGroupName" value="' + row.DiscountGroupName + '" />' +
  3808. '<input type="hidden" id="hfProdDiscountList" value="" />' +
  3809. '<input type="hidden" id="hfProdDiscountApplyTypes" value="" />' +
  3810. '<div class="input-group">' +
  3811. '<input type="text" id="inv_txtdiscount" placeholder="0.00" class="form-control inv_txtaddldiscount" inputmode="numeric" value="' + discValue + '" ' + readonlyDisc + '>' +
  3812. '<div class="input-group-btn">' +
  3813. '<select class="btnInvoice_DiscType btn_inv_DiscType mt-10 border-blue"><option value="Val">Val</option><option value="%">%</option></select>' +
  3814. '</div>' +
  3815. '</div>' +
  3816. '</div>' +
  3817. '</div>' +
  3818. '<div class="col-lg-2 col-md-4 my-15">' +
  3819. '<input type="hidden" class="hfDiscountedAmount" value="0" />' +
  3820. '<input type="hidden" class="hfRowTotalAdjustment" value="' + row.Adjustment + '" />' +
  3821. '<input type="hidden" class="hfAssesableAdjustment" value="" />' +
  3822. '<input type="hidden" class="hfTaxAdjustment" value="" />';
  3823. if (($(".hdn_invoicetypeid").val() == "2") && invoiceid != 0) {
  3824. 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>';
  3825. 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>';
  3826. }
  3827. else {
  3828. 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>';
  3829. }
  3830. html += '</div>' +
  3831. '</div>' +
  3832. '<div class="row"> <span class="col-sm-4"> <p class="ml-35 text-warning ItemConversion"> </p> </span>' +
  3833. '<span class="col-sm-2 text-center SelectedUOMName pl-50"> </span>' +
  3834. '<span class="col-sm-6 text-right UOMCalc"> </span></div>' +
  3835. '<div class="hidden div_MoreDetails clear mt-5 bg-light">' +
  3836. '<div class="row align-items-center mx-5 pt-10">' +
  3837. '<div class="col-lg-2 col-md-4 my-15">' +
  3838. '<div class="floating-label-form-group Desc">' +
  3839. '<label for="from_lbl_Description" id="lbl_Description">Description</label>' +
  3840. '<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"/>' +
  3841. '</div>' +
  3842. '</div>' +
  3843. '<div class="col-lg-2 col-md-4 my-15 hidden" id="div_MultipleUOMs">' +
  3844. '<div class="floating-label-form-group-with-value">' +
  3845. '<label for="from_lbl_UOM" id="lbl_Output">UOM</label>' +
  3846. '<div class="input-group">' +
  3847. '<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>' +
  3848. '</div></div>' +
  3849. '</div>' +
  3850. '<div class="col-lg-2 col-md-4 my-15">' +
  3851. '<div class="floating-label-form-group-with-value">' +
  3852. '<label for="from_lbl_Output" id="lbl_Output">Tax Group<span class="text-danger">*</span></label>' +
  3853. '<div class="input-group">';
  3854. if (row.taxGroupId != 0) {
  3855. 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>' +
  3856. '<input type="hidden" id="hfProdTaxPercent_' + this.rowIndex + '" class="hfProdTaxPercent" value="0" />' +
  3857. '<input type="hidden" id="hfProdTax_' + this.rowIndex + '" class="hfProdTax hidden" value="' + row.taxGroupId + '"/>' +
  3858. '<input type="hidden" class="txtProdTax hidden" value="' + row.taxGroupName + '"/>';
  3859. }
  3860. else {
  3861. 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>' +
  3862. '<input type="hidden" id="hfProdTaxPercent_' + this.rowIndex + '" class="hfProdTaxPercent" value="0" />' +
  3863. '<input type="hidden" id="hfProdTax_' + this.rowIndex + '" class="hfProdTax hidden" value="0"/>' +
  3864. '<input type="hidden" class="txtProdTax hidden" value=""/>';
  3865. }
  3866. html += '</div>' +
  3867. '</div>' +
  3868. '</div>' +
  3869. '<div class="col-lg-3 col-md-4 my-15">' +
  3870. '<div class="floating-label-form-group-with-value">' +
  3871. '<label for="from_lbl_Account" id="lbl_Account">Account<span class="text-danger">*</span></label>';
  3872. if (row.accountId != 0) {
  3873. 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>' +
  3874. '<input type="hidden" id="hf_Account_' + this.rowIndex + '" class="hf_Account" value="' + row.accountId + '" />' +
  3875. '<input type="hidden" id="txt_AccountName_' + this.rowIndex + '" class="txt_AccountName" value="' + row.accountName + '"/>';
  3876. }
  3877. else {
  3878. 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>' +
  3879. '<input type="hidden" id="hf_Account_' + this.rowIndex + '" class="hf_Account" value="0" />' +
  3880. '<input type="hidden" id="txt_AccountName_' + this.rowIndex + '" class="txt_AccountName" value=""/>';
  3881. }
  3882. html += '</div>' +
  3883. '</div>' +
  3884. '<div class="col-lg-3 col-auto align-seld-end ml-auto text-right">' +
  3885. '<label for="from_lbl_Avalilability" id="lbl_Avalilability" class="text-dark mb-0 font-weight-bold mr-10">Availability :</label>' +
  3886. '<span class="prodAvail">' + row.availQty + '</span>' +
  3887. '</div>' +
  3888. '</div>' +
  3889. '<div class="row ml-5 mr-5">' +
  3890. '<div class="col-md-2"> </div>' +
  3891. '</div>' +
  3892. '<div class="row">' +
  3893. '<div class="col-md-12">' +
  3894. '<div class="col-md-3 form-group div_Mrp hidden">' +
  3895. '<div class="floating-label-form-group floating-label focus">' +
  3896. '<input type="hidden" class="hf_PriceList" value="' + row.priceListId + '" />' +
  3897. '<label for="from_lbl_MRP" id="lbl_MRP">MRP</label>' +
  3898. '<input type="text" data-isdynamic="false" class="form-control floating-label-control txt_MRP" data-placeholder="53" placeholder="MRP" data-label="MRP" />' +
  3899. '</div>' +
  3900. '</div>' +
  3901. '</div>' +
  3902. '<div class="orderitemlist"></div>' +
  3903. '</div><div class="accountRow"></div>';
  3904. $(".item-row:last").after(html);
  3905. var element = $(".item-addedrow:last");
  3906. if (IsSplitItem == true) {
  3907. element.addClass('SplitItem');
  3908. }
  3909. InvoiceItem.Instance().loadTaxGroupAutoComplete(element);
  3910. if (row.IsMultipleUOMs && $(".hdn_invoicetypeid").val() == "1") {
  3911. let MultipleUOMs = row.MultipleUoms;
  3912. let html = '<option value="0"> -- Select -- </option>';
  3913. for (var i = 0; i < MultipleUOMs.length; i++) {
  3914. html += '<option value="' + MultipleUOMs[i].SchemaDetailId + '">' + MultipleUOMs[i].AlternateUnitName + ' ( ' + MultipleUOMs[i].DefaultSize + ' ' + MultipleUOMs[i].DefaultUnitName + ' ) </option>';
  3915. }
  3916. element.find(".ddl_MultipleUOMs").html(html);
  3917. element.find("#div_MultipleUOMs").removeClass("hidden");
  3918. InvoiceItem.Instance().UOMs.push({
  3919. ItemId: row.itemId,
  3920. MultipleUOMs: MultipleUOMs
  3921. });
  3922. let SelectedUOM = Number(element.find(".hf_AlternateUnitId").val());
  3923. let DefaultSize = Number(element.find(".hf_DefaultSize").val());
  3924. if (SelectedUOM != 0) {
  3925. element.find(".ddl_MultipleUOMs").val(SelectedUOM);
  3926. let Qty = Number(element.find(".prodQuantity").val());
  3927. let NewQty = Qty / DefaultSize;
  3928. element.find(".prodQuantity").val(NewQty);
  3929. }
  3930. }
  3931. var txtTaxGroup = element.find(".prodTax");
  3932. var hfProdTax = element.find(".hfProdTax");
  3933. var hfAccount = element.find(".hf_Account");
  3934. var txtAccount = element.find(".txt_Account");
  3935. hfAccount.val(row.accountId);
  3936. hfProdTax.val(row.taxGroupId);
  3937. txtTaxGroup.append(new Option(row.taxGroupName, row.taxGroupId, true));
  3938. txtAccount.append(new Option(row.accountName, row.accountId, true));
  3939. InvoiceItem.instance.itemsAutoComplete(element);
  3940. InvoiceItem.instance.itemChange(element, element.find(".prodName").val(), element.find(".selectedItemId"));
  3941. $('.inv_txtaddldiscount').keypress(function (event) {
  3942. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  3943. if (element.find(".selectedItemId").val() == "0") {
  3944. Unibase.Platform.Forms.Components.FormViewer.Instance().showError("Please Select Item");
  3945. element.find('.inv_txtaddldiscount').val(0);
  3946. }
  3947. }
  3948. else {
  3949. event.preventDefault();
  3950. }
  3951. }).on('paste', function (event) {
  3952. var numberRegex = /^\s*[+-]?(\d+|\d*\.\d+|\d+\.\d*)([Ee][+-]?\d+)?\s*$/;
  3953. let val = event.originalEvent["clipboardData"].getData('text');
  3954. if (!numberRegex.test(val)) {
  3955. event.preventDefault();
  3956. return false;
  3957. }
  3958. });
  3959. $('.prodQuantity').keypress(function (event) {
  3960. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  3961. if (element.find(".selectedItemId").val() == "0") {
  3962. Unibase.Platform.Forms.Components.FormViewer.Instance().showError(" Please Select Item");
  3963. element.find(".prodQuantity").val(0);
  3964. }
  3965. }
  3966. else {
  3967. event.preventDefault();
  3968. }
  3969. }).on('paste', function (event) {
  3970. var numberRegex = /^\s*[+-]?(\d+|\d*\.\d+|\d+\.\d*)([Ee][+-]?\d+)?\s*$/;
  3971. let val = event.originalEvent["clipboardData"].getData('text');
  3972. if (!numberRegex.test(val)) {
  3973. event.preventDefault();
  3974. return false;
  3975. }
  3976. });
  3977. $('.prodPrice').keypress(function (event) {
  3978. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  3979. if (element.find(".selectedItemId").val() == "0") {
  3980. Unibase.Platform.Forms.Components.FormViewer.Instance().showError(" Please Select Item");
  3981. element.find('.prodPrice').val(0);
  3982. }
  3983. }
  3984. else {
  3985. event.preventDefault();
  3986. }
  3987. }).on('paste', function (event) {
  3988. var numberRegex = /^\s*[+-]?(\d+|\d*\.\d+|\d+\.\d*)([Ee][+-]?\d+)?\s*$/;
  3989. let val = event.originalEvent["clipboardData"].getData('text');
  3990. if (!numberRegex.test(val)) {
  3991. event.preventDefault();
  3992. return false;
  3993. }
  3994. });
  3995. element.find(".btnInvoice_DiscType option[value='" + activeDiscText + "']").prop("selected", true);
  3996. element.find(".prodPrice,.prodQuantity,.inv_txtaddldiscount").focusin(function () {
  3997. if (element.find($(".prodName")).val() != null || element.find($(".ItemName")).val() != null) {
  3998. $(".div_MoreDetails").addClass("hidden");
  3999. if (!element.parents(".item-row").hasClass('SplitItem'))
  4000. element.find(".div_MoreDetails").removeClass("hidden");
  4001. }
  4002. });
  4003. element.find(".prodName").focusin(function () {
  4004. $(".divMoreDetails").addClass("hidden");
  4005. });
  4006. if (row.description != null && row.description != '' && row.description != 'null') {
  4007. element.find('#txt_Description').val(row.description);
  4008. element.find('#txt_Description').parent(".Desc").addClass("floating-label-form-group-with-value");
  4009. }
  4010. InvoiceItem.Instance().bind(element, row.inventoryTypeId);
  4011. element.find("#inv_txtdiscount").change(function () {
  4012. if (!element.hasClass('SplitItem')) {
  4013. if (element.find(".btnInvoice_DiscType").val() == "%") {
  4014. if (Number(element.find("#inv_txtdiscount").val()) > 100) {
  4015. element.find("#inv_txtdiscount").val("100");
  4016. }
  4017. }
  4018. }
  4019. });
  4020. if (row.TotalRowAmount != 0) {
  4021. if ($(".hdn_invoicetypeid").val() == "2") {
  4022. element.find(".hfRowTotalwithAdjustment").val();
  4023. element.find(".hfRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(row.TotalRowAmount), 2));
  4024. if (element.hasClass('SplitItem'))
  4025. element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(row.TotalRowAmount, 2));
  4026. }
  4027. else {
  4028. element.find('.prodTotalPrice').text('');
  4029. element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(row.TotalRowAmount, 2));
  4030. }
  4031. }
  4032. if (row.TotalDiscount != 0 && row.TotalDiscount != undefined)
  4033. element.find('#inv_txtdiscount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(row.TotalDiscount, 2));
  4034. if (row.invoiceItemId != "0" && ($(".hdn_invoicetypeid").val() == "2")) {
  4035. var x = element.find('.hfRowTotalwithAdjustment');
  4036. element.find('.AdjustmentRow').click(function () {
  4037. InvoiceItem.Instance().editInvItemTaxAllocs(row.invoiceItemId, row.taxGroupId, row.itemId, row.orderItemId, element);
  4038. });
  4039. }
  4040. if (row.IsFoc == true) {
  4041. element.find('.delete').addClass('hidden');
  4042. element.find('.prodQuantity').prop('readonly', 'readonly');
  4043. element.find('.prodPrice').prop('readonly', 'readonly');
  4044. element.find("#inv_txtdiscount").prop('readonly', 'readonly');
  4045. element.find(".btnInvoice_DiscType").prop('disabled', true);
  4046. element.find('.prodQuantity').css('cursor', 'not-allowed');
  4047. element.find('.prodPrice').css('cursor', 'not-allowed');
  4048. element.find("#inv_txtdiscount").css('cursor', 'not-allowed');
  4049. }
  4050. }
  4051. else {
  4052. var element = $(".discount-addedrow:last");
  4053. if (row.inventoryTypeId == 5) {
  4054. element = $(".netdiscount-addedrow:last");
  4055. InvoiceItem.Instance().adddiscountrow(row, row.itemName, row.itemId, true);
  4056. }
  4057. if (row.inventoryTypeId == 6) {
  4058. InvoiceItem.Instance().adddiscountrow(row, row.itemName, row.itemId, false);
  4059. }
  4060. if (row.inventoryTypeId == 7) {
  4061. InvoiceItem.Instance().addExpenseRow(row, row.itemName, row.itemId, true);
  4062. }
  4063. }
  4064. }
  4065. loadTaxGroupAutoComplete(element) {
  4066. var txtTaxGroup = element.find(".prodTax");
  4067. var hfProdTax = element.find(".hfProdTax");
  4068. var hfAccount = element.find(".hf_Account");
  4069. var txtAccount = element.find(".txt_Account");
  4070. var accid = element.find(".hf_Account").val();
  4071. var taxgrpid = element.find(".hfProdTax").val();
  4072. var taxgrptext = element.find(".txtProdTax").val();
  4073. var acctext = element.find(".txt_AccountName").val();
  4074. var applytype = "Sales";
  4075. AutoCompleteHelper.getHelper().Create("#txt_prodTax_" + this.rowIndex, hfProdTax, _appsettings.server_url() + "/apis/v4/bizgaze/transact/tax/taxgroupautocomplete", function (result) {
  4076. if (hfProdTax.val() != '')
  4077. InvoiceItem.Instance().update_tax(element, hfProdTax.val());
  4078. });
  4079. var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/ledgers/ledgerautocomplete';
  4080. const selectId = `#txt_Account_${this.rowIndex}`;
  4081. AutoCompleteHelper.getHelper().Create(selectId, hfAccount, url, function (response) {
  4082. $(selectId).off('select2:open').on('select2:open', (e) => {
  4083. const dropdownEl = $($(e.currentTarget).data('select2').$dropdown);
  4084. dropdownEl.addClass('select2-account-container');
  4085. });
  4086. });
  4087. }
  4088. update_total() {
  4089. var totalAmount = 0;
  4090. var totalDiscountAmount = 0;
  4091. var totalNonDiscountedAmount = 0;
  4092. var totalTaxAmount = 0;
  4093. var totalTaxAdjustment = 0;
  4094. var totalAsseableAdjustment = 0;
  4095. var totalQty = 0;
  4096. var totalDiscountPercent = 0;
  4097. var totalDiscountValue = 0;
  4098. var totalAddlDiscountPercent = 0;
  4099. var totalAddlDiscountValue = 0;
  4100. var totalExpensePercent = 0;
  4101. var totalExpenseValue = 0;
  4102. var addexpenserow_total = 0;
  4103. $('.expense-row-total').each(function (i) {
  4104. var expense_row_total = Number($(this).html());
  4105. addexpenserow_total += expense_row_total;
  4106. });
  4107. var ConsumedWalletValue = 0;
  4108. var totalTaxPercent = 0;
  4109. var totalTaxValue = 0;
  4110. var totalCreditNote = 0;
  4111. var adddiscountrow_total = 0;
  4112. var netadddiscountrow_total = ConsumedWalletValue;
  4113. $('.discount-row-total').each(function (i) {
  4114. var discount_row_total = Number($(this).html());
  4115. adddiscountrow_total += discount_row_total;
  4116. });
  4117. $('.netdiscount-row-total').each(function (i) {
  4118. var discount_row_total = Number($(this).html());
  4119. netadddiscountrow_total += discount_row_total;
  4120. });
  4121. var itemdiscount_total = 0;
  4122. var totalLineAmount_total = 0;
  4123. $('.hfRowTotal').each(function (i) {
  4124. var element = $(this).parents(".item-row");
  4125. if (!element.hasClass('SplitItem')) {
  4126. var totalLineAmount = Number($(this).val());
  4127. if (!isNaN(totalLineAmount))
  4128. totalLineAmount_total += Number(totalLineAmount);
  4129. var discountPercent = 0;
  4130. var discountValue = 0;
  4131. var quantity = Number(element.find(".prodQuantity").val());
  4132. var unitPrice = Number(element.find(".prodPrice").val());
  4133. var exciseAmount = Number(element.find(".exciseAmount").val());
  4134. if (isNaN(exciseAmount))
  4135. exciseAmount = 0;
  4136. var nonexciseAmount = totalLineAmount - exciseAmount;
  4137. if (element.find(".btnInvoice_DiscType option:selected").text().trim() == 'Val' && element.find('.inv_txtaddldiscount').val() != '' && element.find('.inv_txtaddldiscount').val() != undefined) {
  4138. discountValue = Number(element.find('.inv_txtaddldiscount').val());
  4139. }
  4140. else if (element.find(".btnInvoice_DiscType option:selected").text().trim() == '%' && element.find('.inv_txtaddldiscount').val() != '' && element.find('.inv_txtaddldiscount').val() != undefined) {
  4141. discountPercent = Number(element.find('.inv_txtaddldiscount').val());
  4142. }
  4143. else if (element.find(".btnInvoice_DiscType option:selected").text().trim() == 'Mul') {
  4144. if (element.find('#hfProdDiscountList').val() != '' || element.find('#hfProdDiscountApplyTypes').val() != '') {
  4145. var discountsArray = element.find('#hfProdDiscountList').val().toString().split(',');
  4146. var applyTypes = element.find('#hfProdDiscountApplyTypes').val().toString().split(',');
  4147. var price = Number(unitPrice) * Number(quantity);
  4148. var currentAmount = Number(unitPrice) * Number(quantity);
  4149. $.each(discountsArray, function (j) {
  4150. var percent = discountsArray[j];
  4151. var applyType = applyTypes[j];
  4152. var discount = 0;
  4153. if (applyType == 'NET' || applyType == '1') {
  4154. discount = Number(price) * Number(percent) / 100;
  4155. currentAmount -= Number(discount);
  4156. }
  4157. else {
  4158. discount = Number(currentAmount) * Number(percent) / 100;
  4159. currentAmount -= Number(discount);
  4160. }
  4161. discountValue += Number(discount);
  4162. });
  4163. element.find('.inv_txtaddldiscount').val(discountValue);
  4164. }
  4165. else {
  4166. discountValue = Number(element.find('.inv_txtaddldiscount').val());
  4167. }
  4168. }
  4169. if (!isNaN(discountPercent))
  4170. totalDiscountPercent += Number(discountPercent);
  4171. if (!isNaN(discountValue))
  4172. totalAddlDiscountValue += Number(discountValue);
  4173. var discountAmount = 0;
  4174. discountAmount = (Number(nonexciseAmount) * Number(discountPercent) / 100)
  4175. + (Number(quantity) * Number(discountValue));
  4176. if ($(".hdn_invoicetypeid").val() == "1" && (element.find(".hf_IsManualUOM").val() == "true" || element.find(".hf_IsMultipleUOM").val() == "true")) {
  4177. let ConversionQuantity = Number(element.find(".hf_ConversionQuantity").val());
  4178. if (ConversionQuantity > 0)
  4179. discountAmount = (Number(nonexciseAmount) * Number(discountPercent) / 100)
  4180. + (Number(ConversionQuantity) * Number(discountValue));
  4181. }
  4182. discountAmount = Number(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(discountAmount, 2));
  4183. itemdiscount_total += discountAmount;
  4184. var discountedAmount = Number(totalLineAmount) - Number(discountAmount);
  4185. totalDiscountAmount += Number(discountAmount);
  4186. element.find(".hfDiscountedAmount").val(discountAmount);
  4187. let invoiceid = $(".hdn_invoiceid").val();
  4188. if (invoiceid == undefined || invoiceid == "null")
  4189. invoiceid = 0;
  4190. if (($(".hdn_invoicetypeid").val() == "2") && invoiceid != 0) {
  4191. element.find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount, 2));
  4192. element.find(".prodTotalPrice").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount, 2).toString());
  4193. }
  4194. else
  4195. element.find(".prodTotalPrice").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalLineAmount - discountAmount, 2).toString());
  4196. }
  4197. });
  4198. if (InvoiceItem.Instance().SplitedInvoiceItemList.length > 0) {
  4199. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  4200. var totalline_Amount = Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity * InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice);
  4201. var discountAmount = 0;
  4202. var nonexciseAmount = totalline_Amount - Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].exciseAmount);
  4203. discountAmount = (Number(nonexciseAmount) * Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountPercent) / 100)
  4204. + (Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity) * Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountValue));
  4205. discountAmount = Number(discountAmount);
  4206. totalLineAmount_total += Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity * InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice);
  4207. itemdiscount_total += discountAmount;
  4208. totalDiscountAmount += discountAmount;
  4209. }
  4210. }
  4211. var overalldiscountpercent = 0;
  4212. if (adddiscountrow_total != 0) {
  4213. overalldiscountpercent = (100 * Number(adddiscountrow_total)) / Number(totalLineAmount_total);
  4214. overalldiscountpercent = Number(overalldiscountpercent);
  4215. $("#hfOverallDiscountPercent").val(overalldiscountpercent);
  4216. }
  4217. var taxAmounts = [];
  4218. $('.hfRowTotal').each(function (i) {
  4219. var element = $(this).parents(".item-row");
  4220. if (!element.hasClass('SplitItem')) {
  4221. var totalLineAmount = Number($(this).val());
  4222. var quantity = element.find(".prodQuantity").val();
  4223. var UnitPrice = element.find(".prodPrice").val();
  4224. var Discount = element.find("#inv_txtdiscount").val();
  4225. var DiscountType = element.find(".btn_inv_DiscType").val();
  4226. discountAmount = Number(element.find(".hfDiscountedAmount").val()) + (Number(totalLineAmount) * Number(overalldiscountpercent) / 100);
  4227. var assesableAmount = totalLineAmount - discountAmount;
  4228. assesableAmount = Number(assesableAmount);
  4229. if (element.find(".hf_IsMultipleUOM").val() == "true" && $(".hdn_invoicetypeid").val() == "1") {
  4230. let ItemId = Number(element.find(".selectedItemId").val());
  4231. let SelectedUnitId = Number(element.find(".hf_AlternateUnitId").val());
  4232. if (SelectedUnitId == 0 || SelectedUnitId == 1) {
  4233. SelectedUnitId = Number(element.find(".ddl_MultipleUOMs").val());
  4234. }
  4235. if (SelectedUnitId != 0 && SelectedUnitId != 1) {
  4236. let Uom = InvoiceItem.Instance().UOMs.find(x => x.ItemId == ItemId);
  4237. let SelectedUOM = Uom.MultipleUOMs.find(x => x.SchemaDetailId == SelectedUnitId);
  4238. let DefaultSize = SelectedUOM.DefaultSize;
  4239. let AlternateSize = SelectedUOM.AlternateSize;
  4240. quantity = Number(element.find(".prodQuantity").val()) * (AlternateSize / DefaultSize);
  4241. totalLineAmount = Number(assesableAmount) * (AlternateSize / DefaultSize);
  4242. element.find(".prodTotalPrice").text(totalLineAmount);
  4243. element.find(".hfRowTotalwithAdjustment").val(totalLineAmount);
  4244. let Conversion = SelectedUOM.DefaultSize + " " + SelectedUOM.DefaultUnitName + " = " + SelectedUOM.AlternateSize + " " + SelectedUOM.AlternateUnitName;
  4245. element.find(".ItemConversion").text(Conversion);
  4246. element.find(".SelectedUOMName").text('(' + SelectedUOM.DefaultUnitName + ')');
  4247. let UOMCalc = UnitPrice + ' X ' + quantity + ' ( ' + SelectedUOM.AlternateUnitName + ' )';
  4248. if (Discount > 0) {
  4249. if (DiscountType == 'Val') {
  4250. UOMCalc = '(' + UnitPrice + ' - ' + Discount + ')' + ' X ' + quantity + ' ( ' + SelectedUOM.DefaultUnitName + ' )';
  4251. }
  4252. else if (DiscountType == '%') {
  4253. UOMCalc = '(' + UnitPrice + ' - ' + Discount + '%)' + ' X ' + quantity + ' ( ' + SelectedUOM.DefaultUnitName + ' )';
  4254. }
  4255. }
  4256. element.find(".UOMCalc").text(UOMCalc);
  4257. }
  4258. else {
  4259. element.find(".ItemConversion").text("");
  4260. element.find(".UOMCalc").text("");
  4261. element.find(".SelectedUOMName").text("");
  4262. }
  4263. }
  4264. if (element.find(".hf_IsManualUOM").val() == "true" && $(".hdn_invoicetypeid").val() == "1") {
  4265. let ItemId = Number(element.find(".selectedItemId").val());
  4266. let SelectedUnitId = Number(element.find(".hf_AlternateUnitId").val());
  4267. let ConversionQuantity = Number(element.find(".hf_ConversionQuantity").val());
  4268. let AlternateUnitName = element.find(".hf_AlternateUnitName").val();
  4269. let ItemUnitName = element.find(".hf_UnitName").val();
  4270. totalLineAmount = Number(ConversionQuantity) * Number(UnitPrice);
  4271. discountAmount = Number(element.find(".hfDiscountedAmount").val()) + (Number(totalLineAmount) * Number(overalldiscountpercent) / 100);
  4272. var assesableAmount = totalLineAmount - discountAmount;
  4273. assesableAmount = Number(assesableAmount);
  4274. totalLineAmount = assesableAmount;
  4275. if (SelectedUnitId != 0 && SelectedUnitId != 1) {
  4276. element.find(".prodTotalPrice").text(totalLineAmount);
  4277. element.find(".hfRowTotalwithAdjustment").val(totalLineAmount);
  4278. element.find(".SelectedUOMName").text('(' + ItemUnitName + ')');
  4279. let UOMCalc = UnitPrice + ' X ' + ConversionQuantity + ' ( ' + AlternateUnitName + ' )';
  4280. if (Discount > 0) {
  4281. if (DiscountType == 'Val') {
  4282. UOMCalc = '(' + UnitPrice + ' - ' + Discount + ')' + ' X ' + ConversionQuantity + ' ( ' + AlternateUnitName + ' )';
  4283. }
  4284. else if (DiscountType == '%') {
  4285. UOMCalc = '(' + UnitPrice + ' - ' + Discount + '%)' + ' X ' + ConversionQuantity + ' ( ' + AlternateUnitName + ' )';
  4286. }
  4287. }
  4288. element.find(".UOMCalc").text(UOMCalc);
  4289. }
  4290. else {
  4291. element.find(".ItemConversion").text("");
  4292. element.find(".UOMCalc").text("");
  4293. element.find(".SelectedUOMName").text("");
  4294. }
  4295. }
  4296. if (!isNaN(totalLineAmount))
  4297. totalNonDiscountedAmount += Number(totalLineAmount);
  4298. discountAmount = Number(element.find(".hfDiscountedAmount").val()) + (Number(totalLineAmount) * Number(overalldiscountpercent) / 100);
  4299. var assesableAmount = totalLineAmount - discountAmount;
  4300. var taxPercents = element.find(".hfProdTaxPercent").val();
  4301. if (taxPercents != undefined)
  4302. var taxpercentarray = taxPercents.toString().split(',');
  4303. var taxValue = 0;
  4304. var assesableAdjustment = Number(element.find('.hfItemAssesableAdjustmentVal').val());
  4305. var taxAdjustment = Number(element.find('.hfItemTaxAdjsutmentVal').val());
  4306. if (!isNaN(taxAdjustment))
  4307. totalTaxAdjustment += Number(taxAdjustment);
  4308. if (!isNaN(assesableAdjustment))
  4309. totalAsseableAdjustment += Number(assesableAdjustment);
  4310. var cumlTax = 0;
  4311. var cumtaxtotal = 0;
  4312. if ($(".dropdown_istaxinclusive").val() == "true") {
  4313. for (var i = 0; i < taxpercentarray.length; i++) {
  4314. var taxPercentModel1 = taxpercentarray[i];
  4315. var taxPercentM1 = taxPercentModel1.split(":");
  4316. if (!isNaN(Number(taxPercentM1[1])))
  4317. cumlTax += Number(taxPercentM1[1]);
  4318. }
  4319. var currentAmt = Number((Number(assesableAmount) * 100) / (100 + Number(cumlTax)));
  4320. cumtaxtotal = (Number(assesableAmount) - Number(currentAmt));
  4321. }
  4322. if (taxpercentarray != undefined) {
  4323. for (var i = 0; i < taxpercentarray.length; i++) {
  4324. var taxPercentModel = taxpercentarray[i];
  4325. var taxPercentM = taxPercentModel.split(":");
  4326. var ledgerid = taxPercentM[0];
  4327. var taxPercent = Number(taxPercentM[1]);
  4328. let taxAmt = 0;
  4329. if ($(".dropdown_istaxinclusive").val() == "true") {
  4330. taxAmt = Number((taxPercent * cumtaxtotal) / cumlTax);
  4331. }
  4332. else {
  4333. var tax = (Number(assesableAmount) * Number(taxPercent) / 100);
  4334. taxAmt = Number(tax);
  4335. }
  4336. var ledgerexists = false;
  4337. $.map(taxAmounts, function (e, i) {
  4338. if (e.LedgerId == ledgerid) {
  4339. ledgerexists = true;
  4340. taxAmounts[i].TaxAmount = Number(taxAmounts[i].TaxAmount) + Number(taxAmt);
  4341. }
  4342. });
  4343. if (!ledgerexists) {
  4344. taxAmounts.push({
  4345. LedgerId: ledgerid,
  4346. TaxAmount: taxAmt,
  4347. });
  4348. }
  4349. }
  4350. }
  4351. totalAmount += Number(totalLineAmount);
  4352. totalQty += Number(quantity);
  4353. }
  4354. });
  4355. if (InvoiceItem.Instance().SplitedInvoiceItemList.length > 0) {
  4356. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  4357. var TotalLineAmount = Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity * InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice);
  4358. var quantiy = Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity);
  4359. if (!isNaN(TotalLineAmount))
  4360. totalNonDiscountedAmount += Number(TotalLineAmount);
  4361. var discountAmount = (quantiy * Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountValue)) + ((Number(TotalLineAmount) * Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].addlDiscountPercent)) / 100) + (Number(TotalLineAmount) * Number(overalldiscountpercent) / 100);
  4362. ;
  4363. var assesableAmount = TotalLineAmount - discountAmount;
  4364. assesableAmount = Number(assesableAmount);
  4365. var taxPercents = '';
  4366. var instance = this;
  4367. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].TaxPercent == undefined || InvoiceItem.Instance().SplitedInvoiceItemList[i].TaxPercent == 0) {
  4368. var element = "";
  4369. $(".SplitItem").each(function () {
  4370. if ($(this).find(".selectedItemId").val() == InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId) {
  4371. element = $(this);
  4372. taxPercents = element.find('.hfProdTaxPercent').val();
  4373. }
  4374. });
  4375. }
  4376. else
  4377. taxPercents = InvoiceItem.Instance().SplitedInvoiceItemList[i].TaxPercent;
  4378. if (taxPercents != undefined && taxPercents != '')
  4379. var taxpercentarray = taxPercents.split(',');
  4380. var assesableAdjustment = InvoiceItem.Instance().SplitedInvoiceItemList[i].assesableAdjustment;
  4381. var taxAdjustment = InvoiceItem.Instance().SplitedInvoiceItemList[i].taxAdjustment;
  4382. if (!isNaN(taxAdjustment))
  4383. totalTaxAdjustment += Number(taxAdjustment);
  4384. if (!isNaN(assesableAdjustment))
  4385. totalAsseableAdjustment += Number(assesableAdjustment);
  4386. var cumlTax = 0;
  4387. var cumtaxtotal = 0;
  4388. if ($(".dropdown_istaxinclusive").val() == "true") {
  4389. for (var j = 0; j < taxpercentarray.length; j++) {
  4390. var taxPercentModel1 = taxpercentarray[j];
  4391. var taxPercentM1 = taxPercentModel1.split(":");
  4392. if (!isNaN(taxPercentM1[1]))
  4393. cumlTax += Number(taxPercentM1[1]);
  4394. }
  4395. var currentAmt = Number((Number(assesableAmount) * 100) / (100 + Number(cumlTax)));
  4396. cumtaxtotal = (Number(assesableAmount) - Number(currentAmt));
  4397. }
  4398. if (taxpercentarray != undefined) {
  4399. for (var k = 0; k < taxpercentarray.length; k++) {
  4400. if (taxpercentarray[k] != '' && taxpercentarray[k] != null) {
  4401. var taxPercentModel = taxpercentarray[k];
  4402. var taxPercentM = taxPercentModel.split(":");
  4403. var ledgerid = taxPercentM[0];
  4404. var taxPercent = taxPercentM[1];
  4405. var taxAmt = 0;
  4406. if ($(".dropdown_istaxinclusive").val() == "true") {
  4407. taxAmt = Number((taxPercent * cumtaxtotal) / cumlTax);
  4408. }
  4409. else {
  4410. var tax = (Number(assesableAmount) * Number(taxPercent) / 100);
  4411. taxAmt = Number(tax);
  4412. }
  4413. var ledgerexists = false;
  4414. $.map(taxAmounts, function (e, m) {
  4415. if (e.LedgerId == ledgerid) {
  4416. ledgerexists = true;
  4417. taxAmounts[m].TaxAmount = Number(taxAmounts[m].TaxAmount) + Number(taxAmt);
  4418. }
  4419. });
  4420. if (!ledgerexists) {
  4421. taxAmounts.push({
  4422. LedgerId: ledgerid,
  4423. TaxAmount: taxAmt,
  4424. });
  4425. }
  4426. }
  4427. }
  4428. }
  4429. totalAmount += Number(TotalLineAmount);
  4430. totalQty += Number(quantiy);
  4431. }
  4432. }
  4433. var taxAmount = 0;
  4434. var taxAdjustment = 0;
  4435. for (var i = 0; i < taxAmounts.length; i++) {
  4436. if (!isNaN(taxAmounts[i].TaxAmount)) {
  4437. var taxamt = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(taxAmounts[i].TaxAmount, 2);
  4438. taxAmount += Number(taxamt);
  4439. }
  4440. }
  4441. if (!isNaN(totalTaxAdjustment))
  4442. totalTaxAdjustment = totalTaxAdjustment;
  4443. if (!isNaN(totalAsseableAdjustment)) {
  4444. totalAsseableAdjustment = totalAsseableAdjustment;
  4445. }
  4446. else {
  4447. totalAsseableAdjustment = 0;
  4448. }
  4449. if (!isNaN(totalAsseableAdjustment))
  4450. totalAmount += Number(totalAsseableAdjustment);
  4451. totalTaxAmount = Number(taxAmount) + Number(totalTaxAdjustment);
  4452. totalDiscountAmount += adddiscountrow_total;
  4453. var totaltax = totalTaxAmount;
  4454. var grosstotal = totalAmount;
  4455. var creditnotes = 0;
  4456. var assessableadjustment = 0;
  4457. if (!isNaN(Number($("#txt_assessableadjustment").val())))
  4458. assessableadjustment = Number($("#txt_assessableadjustment").val());
  4459. var subtotal = grosstotal - totalDiscountAmount + assessableadjustment;
  4460. let itemCount = $("#" + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId()).find(".InvoiceItems .item-addedrow .selectedItemId[value!='0']").length;
  4461. $("#" + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId()).find("#Item_Count").text(itemCount);
  4462. var overalldiscount = 0;
  4463. var taxadjustment = 0;
  4464. if (!isNaN(Number($('#txt_taxadjustment').val()))) {
  4465. taxadjustment = Number($('#txt_taxadjustment').val());
  4466. }
  4467. totaltax = Number(totaltax) + Number(taxadjustment);
  4468. totaltax = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totaltax, 2);
  4469. $('#totalTax').html(totaltax);
  4470. $('.hdn_taxamount').val(totaltax);
  4471. $('#grosstotal').html(grosstotal);
  4472. $('#totalItemDiscount').html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(itemdiscount_total, 2));
  4473. $('#totalDiscount').html(totalDiscountAmount);
  4474. $("#totalinvoiceqty").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalQty, 2));
  4475. var expense = 0;
  4476. if (!isNaN(Number($('#txtOverallExpenseAmount').val()))) {
  4477. expense = Number($('#txtOverallExpenseAmount').val());
  4478. $("#totalexpense").text(expense);
  4479. }
  4480. var adjustment = 0;
  4481. var nettotal = Number(subtotal) + Number(addexpenserow_total) - Number(overalldiscount) - Number(netadddiscountrow_total) + Number(adjustment);
  4482. if ($(".dropdown_istaxinclusive").val() == "false")
  4483. nettotal += Number(totaltax);
  4484. if ($(".dropdown_istaxinclusive").val() == "true") {
  4485. subtotal = Number(subtotal) - Number(totalTaxAmount);
  4486. }
  4487. subtotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(subtotal, 2);
  4488. $('#subtotal').html(subtotal);
  4489. $('.hdn_assessableamount').val(subtotal);
  4490. $('.hdn_assessableamount').val($('#subtotal').text());
  4491. if ($("#hf_AdjustmentAccountId").val() != undefined) {
  4492. $(".hdn_adjustmentaccountId").val($("#hf_AdjustmentAccountId").val());
  4493. }
  4494. if ($("#chk_tcsapplied").val() != undefined) {
  4495. if ($("#chk_tcsapplied").prop("checked")) {
  4496. let tcstax = 0;
  4497. let tcsrate = 0;
  4498. tcsrate = InvoiceItem.Instance().TaxRate;
  4499. if (tcsrate != 0) {
  4500. tcstax = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number(subtotal) + Number(totalTaxAmount)) * (tcsrate / 100), 2);
  4501. $('.number_tcsamount').val(tcstax);
  4502. nettotal += Number(tcstax);
  4503. $('#lbltcsrate').text("TCS " + tcsrate + " %");
  4504. var tcsadjustment = 0;
  4505. if (!isNaN(Number($('.txt_tcsadjustment').val()))) {
  4506. tcsadjustment = Number($('.txt_tcsadjustment').val());
  4507. }
  4508. $(".number_tcstaxrate").val(tcsrate);
  4509. $('.number_tcsamount').val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number(tcstax) + tcsadjustment), 2));
  4510. nettotal += tcsadjustment;
  4511. }
  4512. }
  4513. else {
  4514. $('.txt_tcsadjustment').val(0);
  4515. $('.number_tcsamount').val(0);
  4516. }
  4517. }
  4518. if ($("#chk_tdsapplied").val() != undefined) {
  4519. if ($("#chk_tdsapplied").prop("checked")) {
  4520. let taxcodeid = $(".txtAutoComplete_tdstaxcodeid").val();
  4521. let tdsrate = $(".number_tdstaxrate").val();
  4522. let tdstax = 0;
  4523. if (tdsrate != 0) {
  4524. tdstax = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(subtotal) * (Number(tdsrate) / 100), 2);
  4525. $('.number_tdsamount').val(tdstax);
  4526. }
  4527. nettotal -= Number(tdstax);
  4528. }
  4529. else {
  4530. $('.txt_tdsadjustment').val(0);
  4531. $('.number_tdsamount').val(0);
  4532. }
  4533. }
  4534. $('.nettotal').html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(nettotal, 2));
  4535. }
  4536. loadItemAutoComplete(element) {
  4537. let userinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
  4538. let sessionid = userinfo.sessionId;
  4539. let postData = null;
  4540. element.find(".prodName").select2({
  4541. placeholder: "Select",
  4542. tags: false,
  4543. allowClear: true,
  4544. theme: "default select2ErrorClass",
  4545. data: [],
  4546. ajax: {
  4547. url: function (request) {
  4548. let reqUrl = _appsettings.server_url() + '/apis/v4/bizgaze/transact/items/getitemsdcitemsandinvoiceitems';
  4549. return reqUrl;
  4550. },
  4551. type: "POST",
  4552. contentType: 'application/json',
  4553. dataType: 'json',
  4554. data: function (params) {
  4555. let Term = params.term;
  4556. sessionid = sessionid.replace('#', '');
  4557. postData = {
  4558. LobId: Number($(".hfAutoCompleteId_lobid").val()),
  4559. ItemIds: InvoiceItem.instance.itemIds,
  4560. term: Term,
  4561. };
  4562. return JSON.stringify(postData);
  4563. },
  4564. beforeSend: function (xhr) {
  4565. if (userinfo !== undefined && userinfo !== null) {
  4566. xhr.setRequestHeader("Authorization", "Basic " + userinfo.sessionId);
  4567. xhr.setRequestHeader('geoposition', userinfo.latd + ':' + userinfo.lgId);
  4568. }
  4569. },
  4570. processResults: function (data) {
  4571. return {
  4572. results: jQuery.map(JSON.parse(data.result), function (item) {
  4573. return {
  4574. id: item.Value,
  4575. text: item.SelectText,
  4576. addlInfo: item.addlData
  4577. };
  4578. })
  4579. };
  4580. },
  4581. },
  4582. });
  4583. }
  4584. itemChange(element, id, hdnAutoId) {
  4585. id = element.find(".prodName option:selected").val();
  4586. element.find(".prodName").change(function () {
  4587. if (id == null || id == 0) {
  4588. id = element.find(".prodName option:selected").val();
  4589. }
  4590. id = element.find(".prodName option:selected").val();
  4591. if (id != 0) {
  4592. var hdnItemId = id;
  4593. element.find(".selectedItemId").val(id);
  4594. if (id.search(':') == -1)
  4595. hdnItemId = id;
  4596. else
  4597. hdnItemId = id.split(':')[1];
  4598. if (element.find(".hfoldItemId").val() != hdnItemId) {
  4599. if (element.find(".orderItemId").val() == "0" && hdnItemId != "") {
  4600. if (element.find(".hfoldItemId").val() != "0" && element.find(".hfoldItemId").val() != undefined && element.find(".hfoldItemId").val() != "") {
  4601. let index = InvoiceItem.Instance().itemIds.indexOf(Number(element.find(".hfoldItemId").val()), 0);
  4602. if (index > -1) {
  4603. InvoiceItem.Instance().itemIds.splice(index, 1);
  4604. }
  4605. }
  4606. InvoiceItem.Instance().itemIds.push(Number(hdnItemId));
  4607. }
  4608. var x = [];
  4609. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  4610. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == element.find(".hfoldItemId").val()) {
  4611. x.push(i);
  4612. }
  4613. }
  4614. for (var i = x.length - 1; i >= 0; i--) {
  4615. InvoiceItem.Instance().SplitedInvoiceItemList.splice(x[i], 1);
  4616. }
  4617. $('.item-row').each(function () {
  4618. if ($(this).find('.hfOfferedItemId').val() == element.find(".hfoldItemId").val())
  4619. $(this).remove();
  4620. });
  4621. element.find(".hfoldItemId").val(hdnItemId);
  4622. element.find(".div_UnitPrice").removeClass('hidden');
  4623. element.find(".div_SplitInvoiceItem").addClass("hidden");
  4624. element.find(".prodQuantity").val(0);
  4625. element.find(".prodPrice").val(0);
  4626. element.find(".prodQuantity").prop('disabled', false);
  4627. element.find('.prodQuantity').css('cursor', 'default');
  4628. element.find('.prodPrice').css('cursor', 'default');
  4629. element.find("#inv_txtdiscount").css('cursor', 'default');
  4630. element.find('#inv_txtdiscount').prop('disabled', false);
  4631. element.find('#inv_txtdiscount').val(0);
  4632. element.find('.btn_inv_DiscType').removeClass('hidden');
  4633. element.find(".btn_inv_DiscType").prop('disabled', false);
  4634. element.find(".prodTax").empty();
  4635. element.find(".txt_Account").empty();
  4636. if (element.hasClass('SplitItem')) {
  4637. element.find(".spn_InvoiceItem").unbind("click", null);
  4638. }
  4639. element.find(".hfRowTotalwithAdjustment").val("0");
  4640. element.find('.prodTotalPrice').text('0');
  4641. $("#txt_Adjustment").val("0");
  4642. InvoiceItem.Instance().update_total();
  4643. InvoiceItem.Instance().TotalAdjustment();
  4644. element.removeClass('SplitItem');
  4645. element.find(".hfMrpId").val(0);
  4646. }
  4647. if ($(hdnAutoId).val().toString().search(':') == -1)
  4648. element.find(".hfoldItemId").val($(hdnAutoId).val());
  4649. else
  4650. element.find(".hfoldItemId").val($(hdnAutoId).val().toString().split(':')[1]);
  4651. var hdnSelectedItemIdVal = 0;
  4652. hdnSelectedItemIdVal = id;
  4653. if (id != 0) {
  4654. id = id;
  4655. var hdnOrderItemIdVal = 0;
  4656. var hdnDcItemIdVal = 0;
  4657. var ids = $(hdnAutoId).val();
  4658. if (ids.toString().search(':') == -1) {
  4659. hdnSelectedItemIdVal = Number($(hdnAutoId).val());
  4660. }
  4661. else {
  4662. var selectedVal = hdnAutoId;
  4663. if (!InvoiceItem.Instance().AutoDc) {
  4664. hdnOrderItemIdVal = Number($(selectedVal).val().toString().split(':')[0]);
  4665. if (InvoiceItem.Instance().orderid != 0 && InvoiceItem.Instance().OrderSettingId == 2)
  4666. hdnOrderItemIdVal = Number($(selectedVal).val().toString().split(':')[0]);
  4667. else {
  4668. hdnDcItemIdVal = Number($(selectedVal).val().toString().split(':')[0]);
  4669. element.find(".dcItemId").val(hdnDcItemIdVal);
  4670. let dcindex = InvoiceItem.Instance().dcItemIds.indexOf(hdnDcItemIdVal, 0);
  4671. if (dcindex == -1)
  4672. InvoiceItem.Instance().dcItemIds.push(hdnDcItemIdVal);
  4673. }
  4674. }
  4675. hdnSelectedItemIdVal = Number($(selectedVal).val().toString().split(':')[1]);
  4676. }
  4677. var item = element.find(".prodName").text();
  4678. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemById(hdnSelectedItemIdVal).then(function (response) {
  4679. var inventarytype = response.result.InventoryTypeId;
  4680. if (inventarytype == 5 || inventarytype == 6) {
  4681. InvoiceItem.Instance().addDiscountRow(element, item, id);
  4682. var elementfordisc = $(".discount-row:last");
  4683. InvoiceItem.Instance().loadItemRowDetails(elementfordisc, 0, hdnDcItemIdVal, hdnSelectedItemIdVal);
  4684. }
  4685. else if (inventarytype == 7) {
  4686. InvoiceItem.Instance().addExpenseRow(element, item, id, true);
  4687. var elementforexp = $(".expense-row:last");
  4688. InvoiceItem.Instance().loadItemRowDetails(elementforexp, 0, hdnDcItemIdVal, hdnSelectedItemIdVal);
  4689. }
  4690. else {
  4691. var itemid = 0;
  4692. if (hdnSelectedItemIdVal == undefined) {
  4693. InvoiceItem.Instance().loadItemRowDetails(element, 0, hdnDcItemIdVal, hdnSelectedItemIdVal);
  4694. }
  4695. else {
  4696. InvoiceItem.Instance().loadItemRowDetails(element, hdnOrderItemIdVal, hdnDcItemIdVal, hdnSelectedItemIdVal);
  4697. }
  4698. }
  4699. });
  4700. }
  4701. }
  4702. });
  4703. }
  4704. itemsAutoComplete(element) {
  4705. var txtAutoSearchCtrl = element.find(".prodName");
  4706. var hdnOrderItemId = element.find(".orderItemId");
  4707. var hdnDcItemId = element.find(".dcItemId");
  4708. var hdnSelectedItemId = element.find(".selectedItemId");
  4709. let lobid = $(".hfAutoCompleteId_lobid").val();
  4710. if ((hdnSelectedItemId).val() != 0 && (hdnSelectedItemId).val() != "") {
  4711. this.itemIds.push(Number((hdnSelectedItemId).val()));
  4712. element.find(".hfoldItemId").val((hdnSelectedItemId).val());
  4713. }
  4714. let hdnAutoId = hdnSelectedItemId;
  4715. let orderid = InvoiceItem.Instance().orderid;
  4716. let dcid = InvoiceItem.Instance().dcid;
  4717. let invoiceid = $(".hdn_invoiceid").val();
  4718. if (invoiceid == undefined || invoiceid == "null")
  4719. invoiceid = 0;
  4720. var url = "";
  4721. var id = 0;
  4722. if ((orderid == 0) && (InvoiceItem.Instance().AutoDc) && InvoiceItem.Instance().OrderSettingId == 0 && ($('#hfInv_IsRetun').val() != "1" && ($(".hdn_refinvoiceid").val() == undefined || $(".hdn_refinvoiceid").val() == 0))) {
  4723. InvoiceItem.instance.loadItemAutoComplete(element);
  4724. }
  4725. else {
  4726. if ((orderid == 0) && (dcid != 0 && InvoiceItem.Instance().AutoDc == false))
  4727. url = _appsettings.server_url() + "/apis/v4/bizgaze/transact/invoices/autodcitemforinvoicewithoutorder/dcid/" + dcid + "/itemids/" + InvoiceItem.Instance().itemIds;
  4728. else if (InvoiceItem.Instance().OrderSettingId == 1)
  4729. url = _appsettings.server_url() + "/apis/v4/bizgaze/transact/invoices/autodcitemforinvoice/dcid/" + dcid + "/itemids/" + InvoiceItem.Instance().dcItemIds;
  4730. else
  4731. url = _appsettings.server_url() + "/apis/v4/bizgaze/transact/invoices/autopendingorderitemforinvoice/orderid/" + orderid + "/itemids/" + InvoiceItem.Instance().itemIds;
  4732. if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && ($('#hfInv_IsRetun').val() == "1" || ($(".hdn_refinvoiceid").val() != undefined && $(".hdn_refinvoiceid").val() != 0))) {
  4733. var refinvoiceid = 0;
  4734. if ($('#hfInv_IsRetun').val() == "1") {
  4735. refinvoiceid = Number(invoiceid);
  4736. $(".hdn_refinvoiceid").val(refinvoiceid);
  4737. }
  4738. if ($(".hdn_refinvoiceid").val() != undefined && $(".hdn_refinvoiceid").val() != 0)
  4739. refinvoiceid = Number($(".hdn_refinvoiceid").val());
  4740. url = _appsettings.server_url() + "/apis/v4/bizgaze/transact/invoices/autopendingreturnitemforinvoice/invoiceid/" + refinvoiceid + "/itemids/" + InvoiceItem.Instance().itemIds;
  4741. }
  4742. AutoCompleteHelper.getHelper().Create(txtAutoSearchCtrl, hdnAutoId, url, function (result) {
  4743. InvoiceItem.instance.itemChange(element, result.id, hdnAutoId);
  4744. });
  4745. }
  4746. InvoiceItem.Instance().loadItemRowDetails(element, hdnOrderItemId.val(), hdnDcItemId.val(), $(hdnSelectedItemId).val());
  4747. }
  4748. addDiscountRow(element, txtAutoSearchCtrl, hdnAutoId) {
  4749. InvoiceItem.Instance().RemoveItem(element);
  4750. InvoiceItem.Instance().adddiscountrow(null, txtAutoSearchCtrl, hdnAutoId, false);
  4751. }
  4752. adddiscountrow(row, txtAutoSearchCtrl, hdnAutoId, applyOnNet) {
  4753. let isemptyrow = false;
  4754. $(".addednetdiscount-row").each(function () {
  4755. if ($(this).find(".txtDiscountName").val() == undefined || $(this).find(".txtDiscountName").val() == null) {
  4756. isemptyrow = true;
  4757. }
  4758. });
  4759. if (isemptyrow) {
  4760. MessageHelper.Instance().showError("Please Select Coupon Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  4761. return false;
  4762. }
  4763. var discountid = 0;
  4764. var discountname = '';
  4765. var description = '';
  4766. var ledgerId = 0;
  4767. var rowname = "discount-row";
  4768. var percent = 0.0;
  4769. var value = 0.0;
  4770. var invoicechargeid = 0;
  4771. var appliedWhole = false;
  4772. var inventorytypeid = 6;
  4773. var readonly = "";
  4774. if (applyOnNet) {
  4775. rowname = "netdiscount-row";
  4776. appliedWhole = true;
  4777. inventorytypeid = 5;
  4778. }
  4779. if ($("#hfDirectInvoice").val() == "0")
  4780. invoicechargeid = 0;
  4781. var html = '<div class="' + rowname + ' added' + rowname + ' row mb-2 mx-0" ' + readonly + '>' +
  4782. '<div class="discount-name col-sm-4">' +
  4783. '<div class="floating-label-form-group min-padding" style="margin-left:20px;border-bottom:0px"><input type="hidden" class="selectedInvoiceChargeId" value="' + invoicechargeid + '" />';
  4784. if (row != null) {
  4785. if (row.addlDiscountPercent != "") {
  4786. percent = row.addlDiscountPercent;
  4787. }
  4788. if (row.addlDiscountValue != "") {
  4789. value = row.addlDiscountValue;
  4790. }
  4791. if (row.description != "" && row.description != null) {
  4792. description = row.description;
  4793. }
  4794. html += '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
  4795. '<input type="hidden" class="orderItemId" value="' + row.orderItemId + '" />' +
  4796. '<input type="hidden" class="dcItemId" value="' + row.dcItemId + '" />' +
  4797. '<input type="hidden" class="selectedInvoiceItemId" value="' + row.invoiceItemId + '" />' +
  4798. '<input type="hidden" class="refInvoiceItemId" value="' + row.RefInvoiceItemId + '" />' +
  4799. '<input type="hidden" class="selectedItemId" value="' + row.itemId + '" />' +
  4800. '<input type="hidden" class="inventorytypeid" value="' + row.itemId + '" />' +
  4801. '<input type="hidden" class="selectedItemName" value="' + row.itemname + '" />' +
  4802. '<input type="hidden" class="hfMrpId" value="' + row.MrpId + '" />' +
  4803. '<input type="hidden" class="offerapplied" value="0" />' +
  4804. '<input type="hidden" class="refNo" value="' + row.refNo + '" />' +
  4805. '<input type="hidden" class="description" value="' + row.description + '" />' +
  4806. '<input type="hidden" class="IsExchangeItem" value="' + row.ExchangeItem + '" />' +
  4807. '<input type="hidden" class="maxQty" value="' + row.maxQty + '" />' +
  4808. '<input type="hidden" class="hf_Account" value="' + row.accountId + '" />' +
  4809. '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="' + row.taxAdjustment + '" />' +
  4810. '<input type="hidden" class="hfProdTax" value="' + row.taxGroupId + '" />' +
  4811. '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="' + row.assesableAdjustment + '" />' +
  4812. '<input type="hidden" class="prodPrice text-center form-control" placeholder="0.00" value="0" />';
  4813. }
  4814. else {
  4815. html += '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
  4816. '<input type="hidden" class="orderItemId" value="0" />' +
  4817. '<input type="hidden" class="dcItemId" value="0" />' +
  4818. '<input type="hidden" class="selectedInvoiceItemId" value="0" />' +
  4819. '<input type="hidden" class="selectedItemName" value="" />' +
  4820. '<input type="hidden" class="refInvoiceItemId" value="0" />' +
  4821. '<input type="hidden" class="selectedItemId" value="0" />' +
  4822. '<input type="hidden" class="inventorytypeid" value="0" />' +
  4823. '<input type="hidden" class="hfMrpId" value="0" />' +
  4824. '<input type="hidden" class="offerapplied" value="0" />' +
  4825. '<input type="hidden" class="refNo" value="0" />' +
  4826. '<input type="hidden" class="description" value="0" />' +
  4827. '<input type="hidden" class="IsExchangeItem" value="0" />' +
  4828. '<input type="hidden" class="maxQty" value="0" />' +
  4829. '<input type="hidden" class="hf_Account" value="0" />' +
  4830. '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="0" />' +
  4831. '<input type="hidden" class="hfProdTax" value="0" />' +
  4832. '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="0" />' +
  4833. '<input type="hidden" class="prodPrice text-center form-control" placeholder="0.00" value="0" />';
  4834. }
  4835. html += '<div class="input-group">' +
  4836. '<input type="hidden" class="hdnChargeTypeId" value="2" />' +
  4837. '<input type="hidden" class="hdnChargeLedgerId" value="' + ledgerId + '" />' +
  4838. '<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>';
  4839. if (rowname == "netdiscount-row") {
  4840. html += '<select type="text" class="txtDiscountName ui-autocomplete form-control text-control readonly' + readonly + '" placeholder=" Discount name" value="' + discountname + '" style="width:100%;"></select>';
  4841. }
  4842. else {
  4843. html += '<select type="text" class="txtDiscountName ui-autocomplete form-control readonly" placeholder=" Discount name" value="' + discountname + '" style="width:100%;"></select>';
  4844. }
  4845. html += '<input type="hidden" class="hfSelectedChargeId" value="' + discountid + '" />' +
  4846. '</div>' +
  4847. '</div></div>' +
  4848. '<div class="col-sm-4">' +
  4849. '<div class="floating-label-form-group min-padding"><input type="text" class="discountDesc form-control" placeholder="Description" value="' + description + '" /></div></div>' +
  4850. '<div class="col-sm-1">' +
  4851. '<div class="floating-label-form-group min-padding"><input type="text" class="percentage text-center form-control" placeholder="%" value="' + percent + '" /></div></div>' +
  4852. '<div class="col-sm-1">' +
  4853. '<div class="floating-label-form-group min-padding"><input type="text" class="fixedvalue text-center form-control" placeholder="0.00" value="' + value + '" /></div></div>' +
  4854. '<div class="col-sm-2 mt-10"><p class="pull-right"><span class="' + rowname + '-total control-label mt-5">0</span></p></div>' +
  4855. '</div>';
  4856. $("." + rowname + ":last").after(html);
  4857. var element = $("." + rowname + ":last");
  4858. InvoiceItem.Instance().bind(element, inventorytypeid);
  4859. if (inventorytypeid == 5)
  4860. InvoiceItem.Instance().GetOnInvoiceDiscountItem(element);
  4861. var txtChargeCode = element.find(".txtDiscountName");
  4862. var hfSelectedChargeId = element.find(".hfSelectedChargeId");
  4863. $(hfSelectedChargeId).val(hdnAutoId);
  4864. if (hdnAutoId != 0) {
  4865. var selecteditem = new Option(txtAutoSearchCtrl, hdnAutoId, true);
  4866. txtChargeCode.append(selecteditem);
  4867. }
  4868. if (rowname == "netdiscount-row" || rowname == "discount-row") {
  4869. var id = 0;
  4870. if (row != null) {
  4871. var selecteditem = new Option(row.itemName, row.itemId, true);
  4872. txtChargeCode.append(selecteditem);
  4873. }
  4874. let typeid = "7";
  4875. if (rowname == "discount-row") {
  4876. typeid = "5,6";
  4877. }
  4878. var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/items/itemautocompletebyinventorytype/inventorytypeid/' + Number(inventorytypeid) + '/lobid/' + $(".hfAutoCompleteId_lobid").val() + '/invoicetypeid/' + $('.hdn_invoicetypeid').val();
  4879. AutoCompleteHelper.getHelper().Create(txtChargeCode, hfSelectedChargeId, url, function (result) {
  4880. if (id != result.id) {
  4881. id = result.id;
  4882. var elementfordisc = $(".netdiscount-row:last");
  4883. var hdnOrderItemIdVal = $(hfSelectedChargeId).val().toString().split(':')[0];
  4884. var hdnSelectedItemIdVal = $(hfSelectedChargeId).val().toString().split(':')[1];
  4885. if (result.addlData != undefined && result.addlData != null) {
  4886. var defaultpercent = Number(result.addlData.split(':')[0]);
  4887. var defaultvalue = Number(result.addlData.split(':')[1]);
  4888. element.find('.percentage').val(defaultpercent);
  4889. element.find('.fixedvalue').val(defaultvalue);
  4890. }
  4891. InvoiceItem.Instance().loadItemRowDetails(element, 0, 0, hdnOrderItemIdVal);
  4892. }
  4893. });
  4894. }
  4895. $('.percentage').keypress(function (event) {
  4896. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  4897. }
  4898. else {
  4899. event.preventDefault();
  4900. }
  4901. }).on('paste', function (event) {
  4902. event.preventDefault();
  4903. });
  4904. $('.fixedvalue').keypress(function (event) {
  4905. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  4906. }
  4907. else {
  4908. event.preventDefault();
  4909. }
  4910. }).on('paste', function (event) {
  4911. event.preventDefault();
  4912. });
  4913. }
  4914. addExpenseRow(row, txtAutoSearchCtrl, hdnAutoId, applyOnNet) {
  4915. let isemptyrow = false;
  4916. $(".addedexpense-row").each(function () {
  4917. if ($(this).find(".txtExpenseName").val() == undefined || $(this).find(".txtExpenseName").val() == null) {
  4918. isemptyrow = true;
  4919. }
  4920. });
  4921. if (isemptyrow) {
  4922. MessageHelper.Instance().showError("Please Select Expense Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  4923. return false;
  4924. }
  4925. var discountid = 0;
  4926. var discountname = '';
  4927. var description = '';
  4928. var ledgerId = 0;
  4929. var rowname = "expense-row";
  4930. var percent = 0.0;
  4931. var value = 0.0;
  4932. var invoicechargeid = 0;
  4933. var appliedWhole = true;
  4934. var inventorytypeid = 7;
  4935. if ($("#hfDirectInvoice").val() == "0")
  4936. invoicechargeid = 0;
  4937. var html = '<div class="' + rowname + ' added' + rowname + ' row mb-2" >' +
  4938. '<div class="expense-name col-sm-4">' +
  4939. '<div class="floating-label-form-group min-padding" style="margin-left:20px;border-bottom:0px"><input type="hidden" class="selectedInvoiceChargeId" value="' + invoicechargeid + '" />';
  4940. if (row != null) {
  4941. if (row.addlDiscountPercent != "") {
  4942. percent = -row.addlDiscountPercent;
  4943. }
  4944. if (row.addlDiscountValue != "") {
  4945. value = -row.addlDiscountValue;
  4946. }
  4947. if (row.description != "") {
  4948. description = row.description;
  4949. }
  4950. html += '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
  4951. '<input type="hidden" class="orderItemId" value="' + row.orderItemId + '" />' +
  4952. '<input type="hidden" class="dcItemId" value="' + row.dcItemId + '" />' +
  4953. '<input type="hidden" class="selectedInvoiceItemId" value="' + row.invoiceItemId + '" />' +
  4954. '<input type="hidden" class="refInvoiceItemId" value="' + row.RefInvoiceItemId + '" />' +
  4955. '<input type="hidden" class="selectedItemId" value="' + row.itemId + '" />' +
  4956. '<input type="hidden" class="inventorytypeid" value="' + row.itemId + '" />' +
  4957. '<input type="hidden" class="selectedItemName" value="' + row.itemname + '" />' +
  4958. '<input type="hidden" class="hfMrpId" value="' + row.MrpId + '" />' +
  4959. '<input type="hidden" class="offerapplied" value="0" />' +
  4960. '<input type="hidden" class="refNo" value="' + row.refNo + '" />' +
  4961. '<input type="hidden" class="description" value="' + row.description + '" />' +
  4962. '<input type="hidden" class="IsExchangeItem" value="' + row.ExchangeItem + '" />' +
  4963. '<input type="hidden" class="maxQty" value="' + row.maxQty + '" />' +
  4964. '<input type="hidden" class="hf_Account" value="' + row.accountId + '" />' +
  4965. '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="' + row.taxAdjustment + '" />' +
  4966. '<input type="hidden" class="hfProdTax" value="' + row.taxGroupId + '" />' +
  4967. '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="' + row.assesableAdjustment + '" />' +
  4968. '<input type="hidden" class="prodPrice text-center form-control" placeholder="0.00" value="0" />';
  4969. }
  4970. else {
  4971. html += '<input type="hidden" class="rowIndex" value="' + this.rowIndex + '" />' +
  4972. '<input type="hidden" class="orderItemId" value="0" />' +
  4973. '<input type="hidden" class="dcItemId" value="0" />' +
  4974. '<input type="hidden" class="selectedInvoiceItemId" value="0" />' +
  4975. '<input type="hidden" class="selectedItemName" value="" />' +
  4976. '<input type="hidden" class="refInvoiceItemId" value="0" />' +
  4977. '<input type="hidden" class="selectedItemId" value="0" />' +
  4978. '<input type="hidden" class="inventorytypeid" value="0" />' +
  4979. '<input type="hidden" class="hfMrpId" value="0" />' +
  4980. '<input type="hidden" class="offerapplied" value="0" />' +
  4981. '<input type="hidden" class="refNo" value="0" />' +
  4982. '<input type="hidden" class="description" value="0" />' +
  4983. '<input type="hidden" class="IsExchangeItem" value="0" />' +
  4984. '<input type="hidden" class="maxQty" value="0" />' +
  4985. '<input type="hidden" class="hf_Account" value="0" />' +
  4986. '<input type="hidden" class="hfItemTaxAdjsutmentVal" value="0" />' +
  4987. '<input type="hidden" class="hfProdTax" value="0" />' +
  4988. '<input type="hidden" class="hfItemAssesableAdjustmentVal" value="0" />' +
  4989. '<input type="hidden" class="prodPrice text-center form-control" placeholder="0.00" value="0" />';
  4990. }
  4991. html += '<div class="input-group">' +
  4992. '<input type="hidden" class="hdnChargeTypeId" value="1" />' +
  4993. '<input type="hidden" class="hdnChargeLedgerId" value="' + ledgerId + '" />' +
  4994. '<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>';
  4995. html += '<select type="text" class="txtExpenseName ui-autocomplete form-control readonly" placeholder=" Expense name" value="' + discountname + '" style="width:100%;"></select>';
  4996. html += '<input type="hidden" class="hfSelectedChargeId" value="' + discountid + '" />' +
  4997. '</div>' +
  4998. '</div></div>' +
  4999. '<div class="col-sm-4">' +
  5000. '<div class="floating-label-form-group min-padding"><input type="text" class="expenseDesc form-control" placeholder="Description" value="' + description + '" /></div></div>' +
  5001. '<div class="col-sm-1">' +
  5002. '<div class="floating-label-form-group min-padding"><input type="text" class="exppercentage text-center form-control" placeholder="%" value="' + percent + '" /></div></div>' +
  5003. '<div class="col-sm-1">' +
  5004. '<div class="floating-label-form-group min-padding"><input type="text" class="expfixedvalue text-center form-control" placeholder="0.00" value="' + value + '" /></div></div>' +
  5005. '<div class="col-sm-2 mt-10"><p class="pull-right"><span class="' + rowname + '-total control-label mt-5">0</span></p></div>' +
  5006. '</div>';
  5007. $("." + rowname + ":last").after(html);
  5008. var element = $("." + rowname + ":last");
  5009. InvoiceItem.Instance().bind(element, inventorytypeid);
  5010. var txtChargeCode = element.find(".txtExpenseName");
  5011. var hfSelectedChargeId = element.find(".hfSelectedChargeId");
  5012. $(hfSelectedChargeId).val(hdnAutoId);
  5013. if (hdnAutoId != 0) {
  5014. var selecteditem = new Option(txtAutoSearchCtrl, hdnAutoId, true);
  5015. txtChargeCode.append(selecteditem);
  5016. }
  5017. if (rowname == "expense-row") {
  5018. var id = 0;
  5019. if (row != null) {
  5020. var selecteditem = new Option(row.itemName, row.itemId, true);
  5021. txtChargeCode.append(selecteditem);
  5022. }
  5023. let typeid = "7";
  5024. var url = _appsettings.server_url() + '/apis/v4/bizgaze/transact/items/itemautocompletebyinventorytype/inventorytypeid/' + Number(inventorytypeid) + '/lobid/' + $(".hfAutoCompleteId_lobid").val() + '/invoicetypeid/' + $('.hdn_invoicetypeid').val();
  5025. AutoCompleteHelper.getHelper().Create(txtChargeCode, hfSelectedChargeId, url, function (result) {
  5026. if (id != result.id) {
  5027. id = result.id;
  5028. var elementfordisc = $(".expense-row:last");
  5029. var hdnOrderItemIdVal = $(hfSelectedChargeId).val().toString().split(':')[0];
  5030. var hdnSelectedItemIdVal = $(hfSelectedChargeId).val().toString().split(':')[1];
  5031. InvoiceItem.Instance().loadItemRowDetails(element, 0, 0, hdnOrderItemIdVal);
  5032. }
  5033. });
  5034. }
  5035. $('.exppercentage').keypress(function (event) {
  5036. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  5037. }
  5038. else {
  5039. event.preventDefault();
  5040. }
  5041. }).on('paste', function (event) {
  5042. event.preventDefault();
  5043. });
  5044. $('.expfixedvalue').keypress(function (event) {
  5045. if ((event.which > 47 && event.which < 58) || (event.which == 46 || event.which == 8)) {
  5046. }
  5047. else {
  5048. event.preventDefault();
  5049. }
  5050. }).on('paste', function (event) {
  5051. event.preventDefault();
  5052. });
  5053. }
  5054. loadItemRowDetails(element, orderItemId, dcItemId, itemId) {
  5055. var instance = this;
  5056. if (orderItemId == '' || ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4"))
  5057. orderItemId = 0;
  5058. if (dcItemId == '' || ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) {
  5059. dcItemId = 0;
  5060. }
  5061. if ((orderItemId != 0 && orderItemId != undefined) || (itemId != 0 && itemId != undefined) || (dcItemId != 0 && dcItemId != undefined)) {
  5062. let lobId = $(".hfAutoCompleteId_lobid").val();
  5063. let billingAddressId = $('.txtAutoComplete_billtoaddressid').val();
  5064. if (billingAddressId == "0" || billingAddressId == "" || billingAddressId == null) {
  5065. MessageHelper.Instance().showError("Please select bill to address", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  5066. return false;
  5067. }
  5068. var portalId = 0;
  5069. var ShipfromAddressId = 0;
  5070. let invoiceid = $(".hdn_invoiceid").val();
  5071. if (invoiceid == undefined)
  5072. invoiceid = 0;
  5073. ShipfromAddressId = Number($(".txtAutoComplete_shipfromaddressid").val());
  5074. var ShiptoAddressId = Number($(".txtAutoComplete_shiptoaddressid").val());
  5075. portalId = Number($(".txtAutoComplete_billfromaddressid").val());
  5076. var MrpId = element.find(".hfMrpId").val();
  5077. if (MrpId == undefined)
  5078. MrpId = 0;
  5079. var isconfirm = false;
  5080. var invoicemode = "1";
  5081. var invoiceType = $('.hdn_invoicetypeid').val();
  5082. if (itemId == undefined)
  5083. itemId = 0;
  5084. var contactId = $(".hdn_organizationid").val();
  5085. if (contactId == 0)
  5086. contactId = $(".hfAutoCompleteId_orgcontactid").val();
  5087. var invoiceapplytype = 1;
  5088. if ($(".hdn_invoicetypeid").val() == "2" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "7") {
  5089. invoiceapplytype = 2;
  5090. }
  5091. let ApplyDate = moment($('.date_journaldate').val().toString(), "DD/MM/YYYY").format("YYYY-MM-DD");
  5092. var refinvoiceid = 0;
  5093. if ($(".hdn_refinvoiceid").val() != undefined && $(".hdn_refinvoiceid").val() != 0)
  5094. refinvoiceid = Number($(".hdn_refinvoiceid").val());
  5095. var post = {
  5096. OrderItemId: Number(orderItemId),
  5097. DcItemId: Number(dcItemId),
  5098. ItemId: Number(itemId),
  5099. BillingAddressId: Number(billingAddressId),
  5100. BillFromAddressId: portalId,
  5101. DefaultPriceListId: 0,
  5102. InvoiceType: Number(invoiceType),
  5103. MrpId: Number(MrpId),
  5104. InvoiceMode: Number(invoicemode),
  5105. isCform: Boolean(isconfirm),
  5106. LobId: Number(lobId),
  5107. contactId: Number(contactId),
  5108. InvoiceApplyType: invoiceapplytype,
  5109. ShipFromAddressId: ShipfromAddressId,
  5110. ShipToAddressId: ShiptoAddressId,
  5111. AutoDC: InvoiceItem.instance.AutoDc,
  5112. InvoiceDate: ApplyDate,
  5113. RefInvoiceId: refinvoiceid
  5114. };
  5115. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemDetails(post).then(function (response) {
  5116. var itemdata = response.result;
  5117. element.find(".selectedItemId").val(itemdata.ItemId);
  5118. if (itemdata.orderItemId == 0)
  5119. element.find(".orderItemId").val(orderItemId);
  5120. else
  5121. element.find(".orderItemId").val(itemdata.OrderItemId);
  5122. itemId = itemdata.ItemId;
  5123. element.find(".spnProdName").text(itemdata.ItemName);
  5124. element.find(".selectedItemName").text(itemdata.ItemName + ' - ' + itemdata.ItemSKU);
  5125. element.find("#inventorytypeid").val(itemdata.InventoryTypeId);
  5126. var prodPrice = element.find(".prodPrice");
  5127. var prodQty = element.find(".prodQuantity");
  5128. var priceListId = element.find(".hfPriceList");
  5129. var isSplitItem = false;
  5130. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  5131. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == itemdata.ItemId) {
  5132. isSplitItem = true;
  5133. }
  5134. }
  5135. if (itemdata.AccountId != 0 && (element.find(".selectedInvoiceItemId").val() == "0" || (itemdata.InventoryTypeId == 5)) && !isSplitItem) {
  5136. var selectedAccount = new Option(itemdata.AccountName, itemdata.AccountId, true);
  5137. element.find(".txt_Account").empty();
  5138. element.find(".txt_Account").append(selectedAccount);
  5139. element.find(".hf_Account").val(itemdata.AccountId);
  5140. element.find(".txt_AccountName").val(itemdata.AccountName);
  5141. }
  5142. if (itemdata.TaxGroupId != 0 && (element.find(".selectedInvoiceItemId").val() == "0" || (itemdata.InventoryTypeId == 5)) && !isSplitItem) {
  5143. var txtTaxGroup = element.find(".prodTax");
  5144. var hfTaxGroupId = element.find(".hfProdTax");
  5145. txtTaxGroup.empty();
  5146. var selectedTaxgrp = new Option(itemdata.TaxGroupName, itemdata.TaxGroupId, true);
  5147. txtTaxGroup.append(selectedTaxgrp);
  5148. element.find(".txtProdTax").val(itemdata.TaxGroupName);
  5149. hfTaxGroupId.val(itemdata.TaxGroupId);
  5150. InvoiceItem.Instance().update_tax(element, itemdata.TaxGroupId);
  5151. }
  5152. if (element.find(".selectedInvoiceItemId").val() == "0" && !isSplitItem) {
  5153. prodPrice.val(itemdata.UnitPrice);
  5154. element.find(".hf_UnitPrice").val(itemdata.UnitPrice);
  5155. priceListId.val(itemdata.PriceListId);
  5156. if (itemdata.AddlDisountValue > 0) {
  5157. element.find(".btnInvoice_DiscType option[value='Val']").prop("selected", true);
  5158. element.find('.inv_txtaddldiscount').val(itemdata.AddlDisountValue);
  5159. }
  5160. else if (itemdata.AddlDiscountPercent > 0) {
  5161. element.find(".btnInvoice_DiscType option[value='%']").prop("selected", true);
  5162. element.find('.inv_txtaddldiscount').val(itemdata.AddlDiscountPercent);
  5163. }
  5164. }
  5165. if ($(".hdn_invoiceid").val() != "0") {
  5166. element.find(".prodAvail").text(itemdata.AvailableQty);
  5167. element.find(".hfAvail").val(itemdata.AvailableQty);
  5168. }
  5169. else {
  5170. element.find(".prodAvail").text(itemdata.AvailableQty);
  5171. element.find(".hfAvail").val(itemdata.AvailableQty);
  5172. }
  5173. var dcid = InvoiceItem.Instance().dcid;
  5174. if (dcid == undefined)
  5175. dcid = 0;
  5176. 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") {
  5177. element.find(".div_UnitPrice").addClass('hidden');
  5178. element.find(".div_SplitInvoiceItem").removeClass("hidden");
  5179. element.find(".prodQuantity").prop('disabled', true);
  5180. element.find(".prodQuantity").css('cursor', "not-allowed");
  5181. element.find("#inv_txtdiscount").prop('disabled', true);
  5182. element.find("#inv_txtdiscount").css('cursor', "not-allowed");
  5183. element.find('.btn_inv_DiscType').addClass('hidden');
  5184. element.find(".btn_inv_DiscType").prop('disabled', true);
  5185. element.find(".prodTax").removeClass("required");
  5186. element.find(".txt_Account").removeClass("required");
  5187. element.addClass('SplitItem');
  5188. var ItemExist = false;
  5189. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  5190. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == itemdata.ItemId) {
  5191. ItemExist = true;
  5192. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId == 0)
  5193. InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice = itemdata.UnitPrice;
  5194. }
  5195. }
  5196. var type = '';
  5197. if (itemdata.EnableBatchNo == true) {
  5198. if (ItemExist == true)
  5199. element.find(".spn_InvoiceItem").text("View BatchNo");
  5200. else
  5201. element.find(".spn_InvoiceItem").text("Select BatchNo");
  5202. type = "BatchNo";
  5203. }
  5204. else if (itemdata.EnableMrp == true) {
  5205. if (ItemExist == true)
  5206. element.find(".spn_InvoiceItem").text("View MRP");
  5207. else
  5208. element.find(".spn_InvoiceItem").text("Select MRP");
  5209. type = "MRP";
  5210. }
  5211. else {
  5212. if (ItemExist == true)
  5213. element.find(".spn_InvoiceItem").text("View SerialNo");
  5214. else
  5215. element.find(".spn_InvoiceItem").text("Select SerialNo");
  5216. type = 'SerialNo';
  5217. }
  5218. let d = InvoiceItem.instance.AutoDc;
  5219. if (d == false && dcItemId != 0 && element.find(".selectedInvoiceItemId").val() == "0") {
  5220. var Isitemadded = false;
  5221. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  5222. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].dcItemId == dcItemId) {
  5223. Isitemadded = true;
  5224. }
  5225. }
  5226. if (Isitemadded == false) {
  5227. var IsSpitItem = false;
  5228. var RowTotal = 0;
  5229. var Discount = 0;
  5230. var Qty = 0;
  5231. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  5232. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == itemdata.ItemId) {
  5233. IsSpitItem = true;
  5234. }
  5235. }
  5236. InvoiceItem.Instance().SplitedInvoiceItemList.push({
  5237. orderItemId: itemdata.OrderItemId,
  5238. invoiceItemId: 0,
  5239. itemName: itemdata.ItemName,
  5240. itemId: itemdata.ItemId,
  5241. itemSKU: itemdata.ItemSKU,
  5242. unitName: itemdata.UnitName,
  5243. packSize: itemdata.PackSize,
  5244. packCount: itemdata.PackCount,
  5245. packs: itemdata.Packs,
  5246. quantity: itemdata.Quantity,
  5247. availPacks: itemdata.AvailablePacks,
  5248. availQty: itemdata.AvailableQty,
  5249. listPrice: 0,
  5250. description: itemdata.Description,
  5251. taxGroupName: itemdata.TaxGroupName,
  5252. taxGroupId: itemdata.TaxGroupId,
  5253. isTaxInclusive: $(".dropdown_istaxinclusive").val(),
  5254. addlDiscountPercent: itemdata.AddlDiscountPercent == undefined ? 0 : itemdata.AddlDiscountPercent,
  5255. addlDiscountValue: itemdata.AddlDisountValue,
  5256. creditNote: 0,
  5257. priceListId: 0,
  5258. batchId: 0,
  5259. unitPrice: itemdata.UnitPrice,
  5260. invoiceallocations: null,
  5261. exciseInvoiceItem: null,
  5262. accountId: itemdata.AccountId,
  5263. accountName: itemdata.AccountName,
  5264. walletId: 0,
  5265. Adjustment: 0,
  5266. IsFoc: false,
  5267. TariffNo: "",
  5268. exciseAmount: 0,
  5269. discountName: "",
  5270. discountId: 0,
  5271. refNo: itemdata.RefNo,
  5272. DiscountGroupId: 0,
  5273. DiscountGroupName: "",
  5274. ExchangeItem: false,
  5275. maxQty: itemdata.Quantity,
  5276. RefInvoiceItemId: 0,
  5277. MrpId: itemdata.MrpId,
  5278. taxAdjustment: 0,
  5279. assesableAdjustment: 0,
  5280. inventoryTypeId: itemdata.InventoryTypeId,
  5281. IsBoMItem: false,
  5282. dcItemId: dcItemId,
  5283. TotalRowAmount: 0,
  5284. TotalDiscount: 0,
  5285. TotalAmount: 0,
  5286. BatchId: itemdata.BatchId,
  5287. });
  5288. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  5289. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == itemdata.ItemId) {
  5290. Qty += InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity;
  5291. var rowtotal = Number((InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity * InvoiceItem.Instance().SplitedInvoiceItemList[i].unitPrice) + InvoiceItem.Instance().SplitedInvoiceItemList[i].exciseAmount + itemdata.Adjustment);
  5292. var nonexiceamount = rowtotal - InvoiceItem.Instance().SplitedInvoiceItemList[i].exciseAmount;
  5293. var discount = ((nonexiceamount * itemdata.AddlDiscountPercent) / 100) + (itemdata.Quantity * itemdata.AddlDisountValue);
  5294. InvoiceItem.Instance().SplitedInvoiceItemList[i].TotalAmount = rowtotal,
  5295. InvoiceItem.Instance().SplitedInvoiceItemList[i].TotalDiscount = discount,
  5296. Discount += discount;
  5297. RowTotal += rowtotal;
  5298. }
  5299. }
  5300. $('.item-row').each(function () {
  5301. if ($(this).find('.selectedItemId').val() == itemdata.ItemId) {
  5302. if ($(".hdn_invoicetypeid").val() == "2") {
  5303. $(this).find(".txtRowTotalwithAdjustment").val();
  5304. $(this).find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number(RowTotal), 3));
  5305. }
  5306. else {
  5307. element.find('.prodTotalPrice').text('');
  5308. element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(RowTotal, 3));
  5309. }
  5310. $(this).find('.prodQuantity').val();
  5311. $(this).find('.prodQuantity').val(Qty);
  5312. $(this).find('#inv_txtdiscount').val();
  5313. $(this).find('#inv_txtdiscount').val(Discount);
  5314. }
  5315. });
  5316. }
  5317. }
  5318. if (orderItemId != 0 && invoiceid == 0) {
  5319. element.find('.prodQuantity').val(itemdata.Quantity);
  5320. }
  5321. element.find(".spn_InvoiceItem").unbind().click(function () {
  5322. InvoiceItem.Instance().createSplitItem(element, itemdata.ItemName + ' - ' + itemdata.ItemSKU, type);
  5323. });
  5324. }
  5325. else if (element.find(".selectedInvoiceItemId").val() == "0" && $('.hdn_invoicetypeid').val() != '3' && $('.hdn_invoicetypeid').val() != '4' && (dcItemId != 0 || (orderItemId != 0 && InvoiceItem.Instance().OrderSettingId == 2))) {
  5326. prodPrice.val(itemdata.UnitPrice);
  5327. prodQty.val(itemdata.Quantity);
  5328. priceListId.val(itemdata.PriceListId);
  5329. element.find('.maxQty').val(itemdata.Quantity);
  5330. }
  5331. if (element.find(".selectedInvoiceItemId").val() == "0" && ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) {
  5332. if (!element.hasClass('SplitItem'))
  5333. prodQty.val(itemdata.Quantity);
  5334. }
  5335. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2") {
  5336. if ((itemdata.IsOfferAvailable == true || itemdata.IsFocAvailable == true) && element.find('.hf_IsFoc').val() != "true") {
  5337. element.find('.btn_offer').removeClass('hidden');
  5338. element.find('.btn_offer').click(function () {
  5339. InvoiceItem.Instance().loadItemOffers(itemdata.ItemId, itemdata.ItemName, invoiceapplytype, contactId, element);
  5340. });
  5341. }
  5342. else
  5343. element.find('.btn_offer').addClass('hidden');
  5344. if (itemdata.IsSpecialPrice == true)
  5345. element.find('.btn_specialPrice').removeClass('hidden');
  5346. }
  5347. if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $("#hf_AppSettingName").val() == "Create Return") {
  5348. element.find(".prodTax").empty();
  5349. element.find(".txt_Account").empty();
  5350. if (itemdata.TaxGroupId != 0) {
  5351. element.find(".txtProdTax").val(itemdata.TaxGroupName);
  5352. element.find(".hfProdTax").val(itemdata.TaxGroupId);
  5353. }
  5354. if (itemdata.AccountId != 0) {
  5355. element.find(".hf_Account").val(itemdata.AccountId);
  5356. element.find(".txt_AccountName").val(itemdata.AccountName);
  5357. }
  5358. }
  5359. if (!element.hasClass('SplitItem')) {
  5360. if ($(".hdn_invoiceid").val() != "0" && $(".hdn_invoiceid").val() != undefined) {
  5361. var taxgrpid = element.find(".hfProdTax").val();
  5362. InvoiceItem.Instance().update_tax(element, taxgrpid);
  5363. }
  5364. }
  5365. if (!element.hasClass('SplitItem') && (element.find(".selectedInvoiceItemId").val() == "0" || element.find(".selectedInvoiceItemId").val() == "undefined")) {
  5366. var txtTaxGroup = element.find(".prodTax");
  5367. var hfTaxGroupId = element.find(".hfProdTax");
  5368. if (itemdata.TaxGroupId != 0) {
  5369. txtTaxGroup.empty();
  5370. var selectedTaxgrp = new Option(itemdata.TaxGroupName, itemdata.TaxGroupId, true);
  5371. txtTaxGroup.append(selectedTaxgrp);
  5372. element.find(".txtProdTax").val(itemdata.TaxGroupName);
  5373. hfTaxGroupId.val(itemdata.TaxGroupId);
  5374. InvoiceItem.Instance().update_tax(element, itemdata.TaxGroupId);
  5375. }
  5376. if (itemdata.AccountId != 0) {
  5377. var selectedAccount = new Option(itemdata.AccountName, itemdata.AccountId, true);
  5378. element.find(".txt_Account").empty();
  5379. element.find(".txt_Account").append(selectedAccount);
  5380. element.find(".hf_Account").val(itemdata.AccountId);
  5381. element.find(".txt_AccountName").val(itemdata.AccountName);
  5382. }
  5383. }
  5384. var unit = element.find(".unit");
  5385. unit.text(itemdata.UnitName);
  5386. var sku = element.find(".prodSKU");
  5387. sku.text(itemdata.ItemSKU);
  5388. var packSize = element.find(".packSize");
  5389. if (itemdata.PackSize == "0")
  5390. packSize.val("1");
  5391. else
  5392. packSize.val(itemdata.PackSize);
  5393. if (itemdata.PackCount == "0")
  5394. element.find(".packCount").val("1");
  5395. else
  5396. element.find(".packCount").val(itemdata.PackCount);
  5397. var rowTotal = 0;
  5398. var rowTotalwithAdjustment = 0;
  5399. if (element.find('.prodPrice').val() != undefined && element.find('.prodQuantity').val() != undefined) {
  5400. rowTotal = element.find('.prodPrice').val().replace("$", "") * element.find('.prodQuantity').val();
  5401. rowTotalwithAdjustment = element.find('.prodPrice').val().replace("$", "") * element.find('.prodQuantity').val();
  5402. }
  5403. if (itemdata.InventoryTypeId == 2) {
  5404. element.find('.prodQuantity').removeAttr('readonly');
  5405. }
  5406. var asbAdjAmt = element.find('.hfItemAssesableAdjustmentVal').val();
  5407. if (!isNaN(asbAdjAmt))
  5408. rowTotalwithAdjustment += Number(asbAdjAmt);
  5409. rowTotalwithAdjustment = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowTotalwithAdjustment, 2);
  5410. if (isNaN(rowTotal)) {
  5411. if (!element.hasClass('SplitItem')) {
  5412. element.find('.prodTotalPrice').html("N/A");
  5413. element.find('.hfRowTotal').val("0");
  5414. element.find('.hfRowTotalwithAdjustment').val("0");
  5415. }
  5416. }
  5417. else {
  5418. if (!element.hasClass('SplitItem')) {
  5419. element.find('.hfRowTotal').val(rowTotal);
  5420. element.find('.hfRowTotalwithAdjustment').val(rowTotalwithAdjustment);
  5421. element.find('.prodTotalPrice').html(rowTotal);
  5422. }
  5423. }
  5424. if (itemdata.AvailableQty <= 0)
  5425. element.find(".prodAvail").addClass('text-danger');
  5426. else
  5427. element.find(".prodAvail").removeClass('text-danger');
  5428. if (!element.hasClass('SplitItem')) {
  5429. InvoiceItem.Instance().update_row_total(element, false);
  5430. }
  5431. InvoiceItem.Instance().loadPriceLists(element, itemId, itemdata.EnableMrp);
  5432. if (itemdata.EnableMrp != true && itemdata.EnableBatchNo != true && itemdata.EnableSerialNo != true) {
  5433. element.find('.hfRowTotalwithAdjustment').css("text-decoration", "underline");
  5434. element.find('.hfRowTotalwithAdjustment').attr("disabled", false);
  5435. element.find('.Adjustmentrow').click(function () {
  5436. if ($(".hdn_invoicetypeid").val() == "2" && element.find('.selectedInvoiceItemId').val() != "0") {
  5437. InvoiceItem.Instance().editInvItemTaxAllocs(element.find('.selectedInvoiceItemId').val(), element.find('.hfProdTax').val(), element.find('.selectedItemId').val(), element.find('.orderItemId').val(), element);
  5438. }
  5439. });
  5440. }
  5441. else {
  5442. element.find('.hfRowTotalwithAdjustment').css("text-decoration", "");
  5443. element.find('.hfRowTotalwithAdjustment').attr("disabled", true);
  5444. }
  5445. if (IsSpitItem == true) {
  5446. element.remove();
  5447. }
  5448. if (itemdata.IsMultilpeUOMs && $(".hdn_invoicetypeid").val() == "1") {
  5449. element.find(".hf_IsMultipleUOM").val(itemdata.IsMultilpeUOMs);
  5450. let MultipleUOMs = itemdata.MultipleUoms;
  5451. let html = '<option value="0"> -- Select -- </option>';
  5452. for (var i = 0; i < MultipleUOMs.length; i++) {
  5453. html += '<option value="' + MultipleUOMs[i].SchemaDetailId + '">' + MultipleUOMs[i].AlternateUnitName + ' ( ' + MultipleUOMs[i].DefaultSize + ' ' + MultipleUOMs[i].DefaultUnitName + ' ) </option>';
  5454. }
  5455. element.find(".ddl_MultipleUOMs").html(html);
  5456. element.find("#div_MultipleUOMs").removeClass("hidden");
  5457. instance.UOMs.push({
  5458. ItemId: itemId,
  5459. MultipleUOMs: MultipleUOMs
  5460. });
  5461. let SelectedUOM = Number(element.find(".hf_AlternateUnitId").val());
  5462. let DefaultSize = Number(element.find(".hf_DefaultSize").val());
  5463. if (SelectedUOM != 0) {
  5464. element.find(".ddl_MultipleUOMs").val(SelectedUOM);
  5465. let Qty = element.find(".prodQuantity").val();
  5466. let NewQty = Qty / DefaultSize;
  5467. element.find(".prodQuantity").val(NewQty);
  5468. }
  5469. }
  5470. else {
  5471. element.find("#div_MultipleUOMs").addClass("hidden");
  5472. }
  5473. if (itemdata.InventoryTypeId == 1)
  5474. InvoiceItem.Instance().GetDiscounts();
  5475. }, function (response) {
  5476. MessageHelper.Instance().showError(JSON.stringify(response.responseJSON.Message), $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  5477. });
  5478. }
  5479. }
  5480. loadItemOffers(ItemId, ItemName, InvoiceApplyType, OrganizationId, element) {
  5481. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/components/invoices/itemofferselection.js", function () {
  5482. Unibase.Platform.Helpers.NavigationHelper.Instance().popup(0, "", Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection.Instance(), function () {
  5483. Bizgaze.Apps.Transact.Components.Invoices.ItemOfferSelection.Instance().LoadOfferItems(OrganizationId, ItemId, ItemName, InvoiceApplyType, element, "Invoice");
  5484. }, Unibase.Platform.Helpers.Size.Large);
  5485. });
  5486. }
  5487. update_tax(element, taxGroupId) {
  5488. var hfTaxValue = element.find(".hfProdTaxValue");
  5489. var hfTaxPercent = element.find(".hfProdTaxPercent");
  5490. var hfProdTax = element.find(".hfProdTax");
  5491. var percentage = 0;
  5492. if (taxGroupId == "0" || taxGroupId == "" || taxGroupId == undefined)
  5493. return percentage;
  5494. let branchid = Number(Unibase.Platform.Membership.Infos.Identity.getSetting("branchid"));
  5495. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().gettaxpercentages(taxGroupId, branchid).then(function (response) {
  5496. var percentstring = "";
  5497. if (response.result.length > 0) {
  5498. var percentages = response.result;
  5499. for (var i = 0; i < percentages.length; i++) {
  5500. percentstring += percentages[i].LedgerId + ":" + percentages[i].Percentage + ",";
  5501. }
  5502. hfTaxPercent.val(percentstring);
  5503. }
  5504. hfTaxValue.val("0");
  5505. InvoiceItem.Instance().update_total();
  5506. InvoiceItem.Instance().TotalAdjustment();
  5507. }, function (response) {
  5508. MessageHelper.Instance().showError(JSON.stringify(response.responseJSON.Message), $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  5509. });
  5510. }
  5511. createSplitItem(element, ItemName, type) {
  5512. let obj = [];
  5513. obj.push({
  5514. type: type,
  5515. element: element,
  5516. });
  5517. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/controls/invoices/splititem.js", function () {
  5518. Unibase.Platform.Helpers.NavigationHelper.Instance().popup(obj, "", Bizgaze.Apps.Transact.Controls.Invoices.SplitItem.Instance(), null, Unibase.Platform.Helpers.Size.Large);
  5519. });
  5520. }
  5521. loadPriceLists(element, itemId, IsEnableMrp) {
  5522. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getLatestMrpByItemId(itemId).then(function (response) {
  5523. if (response.result != null) {
  5524. element.find(".hf_PriceList").val(response.result.PriceListId);
  5525. if (response.result.MrpId != 0 && IsEnableMrp) {
  5526. element.find(".txt_MRP").val(response.result.Mrp);
  5527. element.find(".hfMrpId").val(response.result.MrpId);
  5528. }
  5529. }
  5530. }, function (response) {
  5531. MessageHelper.Instance().showError(JSON.stringify(response.responseJSON.Message), $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  5532. });
  5533. }
  5534. RemoveItem(element) {
  5535. var _this = element.find(".delete");
  5536. var invoiceitemid = _this.parents('.item-row').find(".selectedInvoiceItemId").val();
  5537. if (invoiceitemid == "0") {
  5538. $(element).find(".prodTax").removeClass("required");
  5539. $(element).find(".txt_Account").removeClass("required");
  5540. $(element).addClass("hidden remove_item");
  5541. $(element).find(".selectedItemId").val(0);
  5542. }
  5543. else {
  5544. _this.parents('.item-row').remove();
  5545. InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
  5546. }
  5547. InvoiceItem.Instance().update_total();
  5548. InvoiceItem.Instance().TotalAdjustment();
  5549. }
  5550. bind(element, inventoryTypeId) {
  5551. if (inventoryTypeId != 5 && inventoryTypeId != 6 && inventoryTypeId != 7) {
  5552. element.find(".delete").on('click', function () {
  5553. var _this = $(this);
  5554. var invoiceitemid = _this.parents('.item-row').find(".selectedInvoiceItemId").val();
  5555. if (_this.parents('.item-row').hasClass('SplitItem')) {
  5556. bootbox.confirm("You are about to delete the invoice items. Are you sure?", function (result) {
  5557. if (result == true) {
  5558. var orderid = _this.parents('.item-row').find('.orderItemId').val();
  5559. if ((orderid == 0 || orderid == "0" || orderid == undefined) && _this.parents('.item-row').find('.selectedItemId').val() != 0) {
  5560. let index = InvoiceItem.Instance().itemIds.indexOf(_this.parents('.item-row').find('.selectedItemId').val(), 0);
  5561. if (index == -1)
  5562. index = InvoiceItem.Instance().itemIds.indexOf(Number(_this.parents('.item-row').find('.selectedItemId').val()), 0);
  5563. if (index > -1) {
  5564. InvoiceItem.Instance().itemIds.splice(index, 1);
  5565. }
  5566. }
  5567. else if (orderid != 0) {
  5568. let index = InvoiceItem.Instance().itemIds.indexOf(_this.parents('.item-row').find('.selectedItemId').val(), 0);
  5569. if (index == -1)
  5570. index = InvoiceItem.Instance().itemIds.indexOf(Number(_this.parents('.item-row').find('.selectedItemId').val()), 0);
  5571. if (index > -1) {
  5572. InvoiceItem.Instance().itemIds.splice(index, 1);
  5573. }
  5574. var itemlength = InvoiceItem.Instance().SplitedInvoiceItemList.find(x => x.itemId == Number(_this.parents('.item-row').find('.selectedItemId').val()));
  5575. if (itemlength == undefined) {
  5576. if (_this.parents('.item-row').find('.selectedInvoiceItemId').val() != 0) {
  5577. InvoiceItem.Instance().deleted_invoiceItems.push(Number(_this.parents('.item-row').find('.selectedInvoiceItemId').val()));
  5578. }
  5579. }
  5580. }
  5581. var x = [];
  5582. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  5583. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == _this.parents('.item-row').find('.selectedItemId').val()) {
  5584. x.push(i);
  5585. var index = InvoiceItem.Instance().dcItemIds.indexOf(InvoiceItem.Instance().SplitedInvoiceItemList[i].dcItemId);
  5586. if (index == -1)
  5587. index = InvoiceItem.Instance().dcItemIds.indexOf(Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].dcItemId));
  5588. if (index > -1) {
  5589. InvoiceItem.Instance().dcItemIds.splice(index, 1);
  5590. }
  5591. if (InvoiceItem.Instance().dcItemIds.length == 0)
  5592. InvoiceItem.Instance().dcItemIds = [0];
  5593. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId != 0 && $('#hfInv_IsRetun').val() != "1") {
  5594. InvoiceItem.Instance().deleted_invoiceItems.push(Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].invoiceItemId));
  5595. }
  5596. }
  5597. }
  5598. $('.item-row').each(function () {
  5599. if ($(this).find('.hfOfferedItemId').val() == _this.parents('.item-row').find('.selectedItemId').val() && $(this).find('.hf_IsFoc').val() == "true") {
  5600. if ($(this).find('.selectedInvoiceItemId').val() != 0)
  5601. InvoiceItem.Instance().deleted_invoiceItems.push(Number($(this).find('.selectedInvoiceItemId').val()));
  5602. $(this).remove();
  5603. }
  5604. });
  5605. for (var i = x.length - 1; i >= 0; i--) {
  5606. InvoiceItem.Instance().SplitedInvoiceItemList.splice(x[i], 1);
  5607. }
  5608. _this.parents('.item-row').remove();
  5609. $("#txt_Adjustment").val("0");
  5610. InvoiceItem.Instance().update_total();
  5611. InvoiceItem.Instance().TotalAdjustment();
  5612. InvoiceItem.Instance().GetDiscounts();
  5613. }
  5614. });
  5615. }
  5616. else if (invoiceitemid != 0) {
  5617. bootbox.confirm("You are about to delete the invoice items. Are you sure?", function (result) {
  5618. if (result) {
  5619. var invoiceitemid = _this.parents('.item-row').find(".selectedInvoiceItemId").val();
  5620. InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
  5621. var orderitemid = _this.parents('.item-row').find('.orderItemId').val();
  5622. var dcitemid = _this.parents('.item-row').find('.dcItemId').val();
  5623. if (_this.parents('.item-row').find('.selectedItemId').val() != 0) {
  5624. let index = InvoiceItem.Instance().itemIds.indexOf(_this.parents('.item-row').find('.selectedItemId').val(), 0);
  5625. if (index == -1)
  5626. index = InvoiceItem.Instance().itemIds.indexOf(Number(_this.parents('.item-row').find('.selectedItemId').val()), 0);
  5627. if (index > -1) {
  5628. InvoiceItem.Instance().itemIds.splice(index, 1);
  5629. }
  5630. if (orderitemid != 0 && dcitemid != 0) {
  5631. let dcindex = InvoiceItem.Instance().dcItemIds.indexOf(_this.parents('.item-row').find('.dcItemId').val(), 0);
  5632. if (dcindex == -1)
  5633. dcindex = InvoiceItem.Instance().dcItemIds.indexOf(Number(_this.parents('.item-row').find('.dcItemId').val()), 0);
  5634. InvoiceItem.Instance().dcItemIds.splice(dcindex, 1);
  5635. if (InvoiceItem.Instance().dcItemIds.length == 0)
  5636. InvoiceItem.Instance().dcItemIds.push(0);
  5637. }
  5638. }
  5639. $('.item-row').each(function () {
  5640. if ($(this).find('.hfOfferedItemId').val() == _this.parents('.item-row').find('.selectedItemId').val() && $(this).find('.hf_IsFoc').val() == "true")
  5641. $(this).remove();
  5642. });
  5643. _this.parents('.item-row').remove();
  5644. $("#txt_Adjustment").val("0");
  5645. InvoiceItem.Instance().update_total();
  5646. InvoiceItem.Instance().TotalAdjustment();
  5647. InvoiceItem.Instance().GetDiscounts();
  5648. }
  5649. });
  5650. }
  5651. else {
  5652. bootbox.confirm("You are about to delete the invoice item. Are you sure?", function (result) {
  5653. if (result) {
  5654. var dcitemid = _this.parents('.item-row').find('.dcItemId').val();
  5655. if (_this.parents('.item-row').find('.selectedItemId').val() != 0) {
  5656. let index = InvoiceItem.Instance().itemIds.indexOf(_this.parents('.item-row').find('.selectedItemId').val(), 0);
  5657. if (index == -1)
  5658. index = InvoiceItem.Instance().itemIds.indexOf(Number(_this.parents('.item-row').find('.selectedItemId').val()), 0);
  5659. if (index > -1) {
  5660. InvoiceItem.Instance().itemIds.splice(index, 1);
  5661. if (dcitemid != 0) {
  5662. let dcindex = InvoiceItem.Instance().dcItemIds.indexOf(Number(_this.parents('.item-row').find('.dcItemId').val()), 0);
  5663. InvoiceItem.Instance().dcItemIds.splice(dcindex, 1);
  5664. if (InvoiceItem.Instance().dcItemIds.length == 0)
  5665. InvoiceItem.Instance().dcItemIds.push(0);
  5666. }
  5667. }
  5668. }
  5669. var x = [];
  5670. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  5671. if (InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId == _this.parents('.item-row').find('.selectedItemId').val()) {
  5672. x.push(i);
  5673. }
  5674. }
  5675. for (var i = x.length - 1; i >= 0; i--) {
  5676. InvoiceItem.Instance().SplitedInvoiceItemList.splice(x[i], 1);
  5677. }
  5678. $('.item-row').each(function () {
  5679. if ($(this).find('.hfOfferedItemId').val() == _this.parents('.item-row').find('.selectedItemId').val() && $(this).find('.hf_IsFoc').val() == "true")
  5680. $(this).remove();
  5681. });
  5682. _this.parents('.item-row').remove();
  5683. $("#txt_Adjustment").val("0");
  5684. InvoiceItem.Instance().update_total();
  5685. InvoiceItem.Instance().TotalAdjustment();
  5686. InvoiceItem.Instance().GetDiscounts();
  5687. }
  5688. });
  5689. }
  5690. });
  5691. element.find(".prodPrice,.prodQuantity,.exciseAmount").blur(function () {
  5692. InvoiceItem.Instance().update_price(element);
  5693. });
  5694. element.find(".prodQuantity").change(function () {
  5695. InvoiceItem.Instance().CheckOfferForItem($(this));
  5696. });
  5697. element.find(".prodTax").blur(function () {
  5698. InvoiceItem.Instance().update_total();
  5699. InvoiceItem.Instance().TotalAdjustment();
  5700. });
  5701. element.find(".prodPrice").blur(function () {
  5702. InvoiceItem.Instance().update_total();
  5703. InvoiceItem.Instance().TotalAdjustment();
  5704. InvoiceItem.Instance().GetDiscounts();
  5705. });
  5706. element.find(".prodQuantity").blur(function () {
  5707. InvoiceItem.Instance().update_total();
  5708. InvoiceItem.Instance().TotalAdjustment();
  5709. InvoiceItem.Instance().GetDiscounts();
  5710. });
  5711. element.find('.ddl_MultipleUOMs').change(function () {
  5712. InvoiceItem.Instance().update_row_total(element, true);
  5713. });
  5714. element.find(".inv_txtaddldiscount").blur(function () {
  5715. InvoiceItem.Instance().update_total();
  5716. InvoiceItem.Instance().TotalAdjustment();
  5717. InvoiceItem.Instance().GetDiscounts();
  5718. });
  5719. element.find(".inv_txtaddldiscount").blur(InvoiceItem.Instance().update_discount_total);
  5720. element.find(".btnOrder_DiscType").text('Val');
  5721. element.find(".btnInvoice_DiscType").change(function () {
  5722. if (element.find(".btnInvoice_DiscType option:selected").text().trim() == 'Val') {
  5723. element.find('#hfProdDiscountGroupId').val(0);
  5724. element.find('#hfProdDiscountGroupName').val('');
  5725. element.find('.inv_txtaddldiscount').prop('disabled', false);
  5726. }
  5727. else if (element.find(".btnInvoice_DiscType option:selected").text().trim() == '%') {
  5728. element.find('#hfProdDiscountGroupId').val(0);
  5729. element.find('#hfProdDiscountGroupName').val('');
  5730. element.find('.inv_txtaddldiscount').prop('disabled', false);
  5731. if (Number(element.find("#inv_txtdiscount").val()) > 100) {
  5732. element.find("#inv_txtdiscount").val("100");
  5733. }
  5734. }
  5735. InvoiceItem.Instance().update_total();
  5736. InvoiceItem.Instance().TotalAdjustment();
  5737. InvoiceItem.Instance().GetDiscounts();
  5738. });
  5739. }
  5740. else {
  5741. if (inventoryTypeId == 6) {
  5742. element.find(".delete").on('click', function () {
  5743. var dis = $(".fixedvalue").val();
  5744. var _this = $(this);
  5745. var selectedinvoiceitemid = element.find(".selectedInvoiceItemId").val();
  5746. if (selectedinvoiceitemid != 0) {
  5747. bootbox.confirm("You are about to delete the discount item. Are you sure?", function (result) {
  5748. if (result) {
  5749. var rowIndex = element.find(".rowIndex").val();
  5750. var invoiceitemid = _this.parents('.discount-row').find(".selectedInvoiceItemId").val();
  5751. _this.parents('.discount-row').remove();
  5752. InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
  5753. }
  5754. InvoiceItem.Instance().update_total();
  5755. InvoiceItem.Instance().TotalAdjustment();
  5756. });
  5757. }
  5758. else {
  5759. _this.parents('.discount-row').remove();
  5760. InvoiceItem.Instance().update_total();
  5761. InvoiceItem.Instance().TotalAdjustment();
  5762. }
  5763. InvoiceItem.Instance().update_total();
  5764. InvoiceItem.Instance().TotalAdjustment();
  5765. });
  5766. }
  5767. else if (inventoryTypeId == 5) {
  5768. element.find(".delete").on('click', function () {
  5769. var dis = $(".fixedvalue").val();
  5770. var _this = $(this);
  5771. var selectedinvoiceitemid = element.find(".selectedInvoiceItemId").val();
  5772. if (selectedinvoiceitemid != 0) {
  5773. bootbox.confirm("You are about to delete the coupon item. Are you sure?", function (result) {
  5774. if (result) {
  5775. var rowIndex = element.find(".rowIndex").val();
  5776. var invoiceitemid = _this.parents('.netdiscount-row').find(".selectedInvoiceItemId").val();
  5777. _this.parents('.netdiscount-row').remove();
  5778. InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
  5779. }
  5780. InvoiceItem.Instance().update_total();
  5781. InvoiceItem.Instance().TotalAdjustment();
  5782. });
  5783. }
  5784. else {
  5785. if (_this.parents('.OnInvoiceOfferItem').length != 0) {
  5786. InvoiceItem.Instance().isOfferChargeApplied = false;
  5787. $(".hdn_isofferchargeapplied").val('false');
  5788. }
  5789. _this.parents('.netdiscount-row').remove();
  5790. InvoiceItem.Instance().update_total();
  5791. InvoiceItem.Instance().TotalAdjustment();
  5792. }
  5793. InvoiceItem.Instance().update_total();
  5794. InvoiceItem.Instance().TotalAdjustment();
  5795. });
  5796. }
  5797. else if (inventoryTypeId == 7) {
  5798. element.find(".delete").on('click', function () {
  5799. var dis = $(".expfixedvalue").val();
  5800. var _this = $(this);
  5801. var selectedinvoiceitemid = element.find(".selectedInvoiceItemId").val();
  5802. if (selectedinvoiceitemid != 0) {
  5803. bootbox.confirm("You are about to delete the coupon item. Are you sure?", function (result) {
  5804. if (result) {
  5805. var rowIndex = element.find(".rowIndex").val();
  5806. var invoiceitemid = _this.parents('.expense-row').find(".selectedInvoiceItemId").val();
  5807. _this.parents('.expense-row').remove();
  5808. InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
  5809. }
  5810. InvoiceItem.Instance().update_total();
  5811. InvoiceItem.Instance().TotalAdjustment();
  5812. });
  5813. }
  5814. else {
  5815. _this.parents('.expense-row').remove();
  5816. InvoiceItem.Instance().update_total();
  5817. InvoiceItem.Instance().TotalAdjustment();
  5818. }
  5819. InvoiceItem.Instance().update_total();
  5820. InvoiceItem.Instance().TotalAdjustment();
  5821. });
  5822. }
  5823. $(".percentage").on('blur', function () {
  5824. InvoiceItem.Instance().update_discount_total();
  5825. });
  5826. $(".fixedvalue").on('blur', function () {
  5827. InvoiceItem.Instance().update_discount_total();
  5828. });
  5829. $(".expfixedvalue").on('blur', function () {
  5830. InvoiceItem.Instance().update_expense_total();
  5831. });
  5832. $(".exppercentage").on('blur', function () {
  5833. InvoiceItem.Instance().update_expense_total();
  5834. });
  5835. InvoiceItem.Instance().update_discount_total();
  5836. InvoiceItem.Instance().update_expense_total();
  5837. }
  5838. }
  5839. update_price(element) {
  5840. InvoiceItem.Instance().update_row_total(element, true);
  5841. }
  5842. update_row_total(element, checkavailability) {
  5843. var row = element;
  5844. var item = Number(row.find('.selectedItemId').val());
  5845. var inventorytypeid = 0;
  5846. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/inventory/itemmanager.js", function () {
  5847. Bizgaze.Apps.Transact.Managers.ItemManager.Instance().getItem(item).then(function (response) {
  5848. inventorytypeid = response.result.InventoryTypeId;
  5849. if (item == 0) {
  5850. row.find(".prodQuantity").val(0);
  5851. row.find(".prodPrice").val(0);
  5852. MessageHelper.Instance().showError("Please Select Item", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  5853. return false;
  5854. }
  5855. if (checkavailability == true) {
  5856. let BranchId = 0;
  5857. var SettingName = "";
  5858. if ($(".hdn_invoicetypeid").val() == "1") {
  5859. SettingName = "Bizgaze_Extension_Transact_Orders_Setting_Sales_CheckAvailability";
  5860. BranchId = Number($(".txtAutoComplete_billfromaddressid option:selected").val());
  5861. }
  5862. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/managers/orders/ordermanager.js", function () {
  5863. let LobId = Number($(".txtAutoComplete_lobid option:selected").val());
  5864. Bizgaze.Apps.Transact.Managers.OrderManager.Instance().getOrderSettingsByLob(SettingName, LobId, BranchId).then(function (res) {
  5865. let IsCheckAvailability_Lob = res.result.SettingValue;
  5866. if (IsCheckAvailability_Lob == "Yes" || res.result == "") {
  5867. if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "4") && (InvoiceItem.Instance().OrderSettingId == 2 || InvoiceItem.Instance().AutoDc == true)) {
  5868. if ($(".hdn_invoiceid").val() == "0") {
  5869. if (Number(row.find('.prodQuantity').val()) > Number(row.find('.prodAvail').text()) && inventorytypeid != 2) {
  5870. MessageHelper.Instance().showError("Check available quantity", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  5871. if (Number(row.find('.prodAvail').text()) > 0)
  5872. row.find('.prodQuantity').val(row.find('.prodAvail').text());
  5873. else {
  5874. row.find('.prodQuantity').val("0");
  5875. }
  5876. }
  5877. }
  5878. else {
  5879. let Qty = Number(row.find('.prodQuantity').val());
  5880. let AvQty = Number(row.find('.prodAvail').text()) + Number(row.find('.Qty').val());
  5881. if (Qty > AvQty && inventorytypeid != 2) {
  5882. MessageHelper.Instance().showError("Check available quantity", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  5883. row.find('.prodQuantity').val(row.find('.Qty').val());
  5884. }
  5885. }
  5886. }
  5887. if (row.find('.orderItemId').val() != 0 && !row.hasClass('.SplitItem')) {
  5888. if (Number(row.find('.prodQuantity').val()) > Number(row.find('.maxQty').val())) {
  5889. row.find('.prodQuantity').val(Number(row.find('.maxQty').val()));
  5890. InvoiceItem.Instance().update_row_total(element, checkavailability);
  5891. InvoiceItem.Instance().GetDiscounts();
  5892. }
  5893. }
  5894. }
  5895. });
  5896. });
  5897. }
  5898. var rowTotal = 0;
  5899. var rowTotalwithAdjustment = 0;
  5900. if (row.find('.prodPrice').val() != undefined && row.find('.prodQuantity').val() != undefined) {
  5901. rowTotal = row.find('.prodPrice').val().replace("$", "") * (Number(row.find('.prodQuantity').val()));
  5902. rowTotalwithAdjustment = row.find('.prodPrice').val().replace("$", "") * (Number(row.find('.prodQuantity').val()));
  5903. }
  5904. rowTotal += Number(row.find('.hfRowTotalAdjustment').val());
  5905. rowTotalwithAdjustment += Number(row.find('.hfRowTotalAdjustment').val());
  5906. var exciseAmount = element.find(".exciseAmount").val();
  5907. if (exciseAmount != undefined) {
  5908. rowTotal += Number(exciseAmount);
  5909. rowTotalwithAdjustment += Number(exciseAmount);
  5910. }
  5911. var asbAdjAmt = 0;
  5912. asbAdjAmt = row.find('.hfItemAssesableAdjustmentVal').val();
  5913. if (!isNaN(asbAdjAmt))
  5914. rowTotalwithAdjustment += Number(asbAdjAmt);
  5915. rowTotal = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowTotal, 2);
  5916. rowTotalwithAdjustment = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(rowTotalwithAdjustment, 2);
  5917. if (isNaN(rowTotal)) {
  5918. element.find('.prodTotalPrice').html("N/A");
  5919. element.find('.hfRowTotal').val("0");
  5920. element.find('.hfRowTotalwithAdjustment').val("0");
  5921. }
  5922. else {
  5923. element.find('.hfRowTotal').val(rowTotal);
  5924. element.find('.hfRowTotalwithAdjustment').val(rowTotalwithAdjustment);
  5925. element.find('.prodTotalPrice').html(rowTotal);
  5926. }
  5927. InvoiceItem.Instance().update_total();
  5928. InvoiceItem.Instance().TotalAdjustment();
  5929. InvoiceItem.Instance().update_discount_total();
  5930. InvoiceItem.Instance().update_expense_total();
  5931. });
  5932. });
  5933. }
  5934. CheckOfferForItem(control) {
  5935. var element = control.parents('.item-row');
  5936. if (element.find('.orderItemId').val() == 0) {
  5937. if ($(".hdn_invoicetypeid").val() == "1") {
  5938. if (Number(element.find('.prodQuantity').val()) <= Number(element.find('.prodAvail').text())) {
  5939. InvoiceItem.Instance().GetPlanItems(element.find('.selectedItemId').val(), element.find('.prodQuantity').val(), element);
  5940. }
  5941. }
  5942. else if ($(".hdn_invoicetypeid").val() == "2") {
  5943. InvoiceItem.Instance().GetPlanItems(element.find('.selectedItemId').val(), element.find('.prodQuantity').val(), element);
  5944. }
  5945. }
  5946. }
  5947. GetPlanItems(ItemId, Quantity, element) {
  5948. var contactId = $(".hdn_organizationid").val();
  5949. if (contactId == 0)
  5950. contactId = $(".hfAutoCompleteId_orgcontactid").val();
  5951. var invoiceapplytype = 1;
  5952. var RowTotal = Number(element.find('.prodTotalPrice').text());
  5953. if ($(".hdn_invoicetypeid").val() == "2") {
  5954. invoiceapplytype = 2;
  5955. RowTotal = Number(element.find(".txtRowTotalwithAdjustment").val());
  5956. }
  5957. $('.item-row').each(function () {
  5958. if ($(this).find('.hfOfferedItemId').val() == ItemId) {
  5959. if ($(this).find('.selectedInvoiceItemId').val() != "0")
  5960. InvoiceItem.Instance().deleted_invoiceItems.push(Number($(this).find('.selectedInvoiceItemId').val()));
  5961. $(this).remove();
  5962. }
  5963. });
  5964. let ApplyDate = moment($('.hfdate_journaldate').val().toString(), "YYYY/MM/DD").format("YYYY-MM-DD");
  5965. Bizgaze.Apps.Transact.Managers.OfferManager.Instance().getoffers(ItemId, Number(contactId), Quantity, invoiceapplytype, RowTotal, ApplyDate).then(function (result) {
  5966. var response = result.result;
  5967. if (response.length > 0) {
  5968. for (var j = 0; j < response.length; j++) {
  5969. if (element.hasClass('SplitItem')) {
  5970. var RowTotal = 0;
  5971. var rowDiscount = 0;
  5972. for (var k = 0; k < InvoiceItem.Instance().SplitedInvoiceItemList.length; k++) {
  5973. if (InvoiceItem.Instance().SplitedInvoiceItemList[k].itemId == ItemId) {
  5974. var discValue = 0;
  5975. var discPercent = 0;
  5976. var Itemrow = InvoiceItem.Instance().SplitedInvoiceItemList[k];
  5977. if (response[j].PayoutValue > 0) {
  5978. discValue = response[j].PayoutValue;
  5979. Itemrow.addlDiscountValue = discValue;
  5980. Itemrow.addlDiscountPercent = 0;
  5981. }
  5982. else if (response[j].PayoutPercent > 0) {
  5983. discPercent = response[j].PayoutPercent;
  5984. Itemrow.addlDiscountPercent = discPercent;
  5985. Itemrow.addlDiscountValue = 0;
  5986. }
  5987. var TotalLineAmount = (Number(Itemrow.quantity) * Number(Itemrow.unitPrice)) + Number(Itemrow.exciseAmount) + Number(Itemrow.Adjustment) + Number(Itemrow.assesableAdjustment);
  5988. var NonExciseAmount = TotalLineAmount - Number(Itemrow.exciseAmount);
  5989. var DiscountAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(NonExciseAmount * (Number(Itemrow.addlDiscountPercent) / 100) + (Number(Itemrow.quantity) * Number(Itemrow.addlDiscountValue)), 2);
  5990. Itemrow.DiscountedAmount = DiscountAmount;
  5991. Itemrow.TotalAmount = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((TotalLineAmount - Number(DiscountAmount)), 3);
  5992. RowTotal += Number(Itemrow.TotalAmount);
  5993. rowDiscount += Number(DiscountAmount);
  5994. }
  5995. }
  5996. if ($(".hdn_invoicetypeid").val() == "2") {
  5997. element.find(".txtRowTotalwithAdjustment").val();
  5998. element.find(".txtRowTotalwithAdjustment").val(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(RowTotal, 3));
  5999. element.find('#inv_txtdiscount').val();
  6000. element.find('#inv_txtdiscount').val(rowDiscount);
  6001. }
  6002. else {
  6003. element.find('.prodTotalPrice').text('');
  6004. element.find('.prodTotalPrice').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(RowTotal, 3));
  6005. element.find('#inv_txtdiscount').val();
  6006. element.find('#inv_txtdiscount').val(rowDiscount);
  6007. }
  6008. }
  6009. else {
  6010. var discValue = 0;
  6011. var discPercent = 0;
  6012. if (response[j].PayoutValue > 0) {
  6013. discValue = response[j].PayoutValue;
  6014. element.find(".btnInvoice_DiscType option[value='Val']").prop("selected", true);
  6015. element.find('.inv_txtaddldiscount').val(discValue);
  6016. }
  6017. else if (response[j].PayoutPercent > 0) {
  6018. discPercent = response[j].PayoutPercent;
  6019. element.find(".btnInvoice_DiscType option[value='%']").prop("selected", true);
  6020. element.find('.inv_txtaddldiscount').val(discPercent);
  6021. }
  6022. }
  6023. if (response[j].ItemVolumePayouts.length > 0) {
  6024. var OfferItems = response[j].ItemVolumePayouts;
  6025. for (var i = 0; i < OfferItems.length; i++) {
  6026. var emptyRow = {
  6027. orderItemId: 0,
  6028. invoiceItemId: 0,
  6029. itemName: OfferItems[i].ItemName,
  6030. itemId: OfferItems[i].ItemId,
  6031. itemSKU: "",
  6032. unitName: "",
  6033. packSize: 0,
  6034. packCount: 0,
  6035. packs: 0,
  6036. quantity: OfferItems[i].Quantity,
  6037. availPacks: 0,
  6038. availQty: 0,
  6039. listPrice: 0,
  6040. description: OfferItems[i].Description,
  6041. taxGroupName: "",
  6042. taxGroupId: 0,
  6043. isTaxInclusive: $("#hfIsTaxInclusive").val(),
  6044. addlDiscountPercent: OfferItems[i].Discount,
  6045. addlDiscountValue: 0,
  6046. creditNote: 0,
  6047. priceListId: 0,
  6048. batchId: 0,
  6049. unitPrice: 0,
  6050. invoiceallocations: null,
  6051. exciseInvoiceItem: null,
  6052. accountId: 0,
  6053. accountName: "",
  6054. walletId: 0,
  6055. Adjustment: 0,
  6056. TariffNo: "",
  6057. exciseAmount: 0,
  6058. discountName: "",
  6059. discountId: 0,
  6060. refNo: "",
  6061. DiscountGroupId: 0,
  6062. DiscountGroupName: '',
  6063. RefInvoiceItemId: 0,
  6064. MrpId: 0,
  6065. taxAdjustment: 0,
  6066. assesableAdjustment: 0,
  6067. inventoryTypeId: 0,
  6068. dcItemId: 0,
  6069. TotalRowAmount: 0,
  6070. maxQty: 0,
  6071. OfferItemId: ItemId,
  6072. IsFoc: true,
  6073. };
  6074. InvoiceItem.Instance().addDataRow(emptyRow, false);
  6075. }
  6076. }
  6077. }
  6078. }
  6079. });
  6080. }
  6081. TotalAdjustment() {
  6082. if ($('#chk_AutoAdjustment').is(':checked')) {
  6083. var total = $('.nettotal').text();
  6084. var splitTotal = total.split('.');
  6085. var AdjustmentValue = 0;
  6086. var splitedAdjestment = 0;
  6087. $("#txt_Adjustment").val(0);
  6088. $(".hdn_adjustment").val(0);
  6089. if (!isNaN(Number($('#txt_Adjustment').val()))) {
  6090. AdjustmentValue = Number($('#txt_Adjustment').val());
  6091. }
  6092. if (Number(splitTotal[1]) > 0) {
  6093. if (Number(splitTotal[1]) >= 50) {
  6094. splitedAdjestment = (100 - Number(splitTotal[1])) / 100;
  6095. AdjustmentValue += splitedAdjestment;
  6096. $('#txt_Adjustment').val(Number(AdjustmentValue).toFixed(2)).blur();
  6097. $(".hdn_adjustment").val($('#txt_Adjustment').val());
  6098. $("#span_Adjustment").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(AdjustmentValue, 2));
  6099. $('.nettotal').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number(total) + AdjustmentValue), 2));
  6100. }
  6101. else {
  6102. splitedAdjestment = Number(splitTotal[1]) / 100;
  6103. AdjustmentValue -= splitedAdjestment;
  6104. $('#txt_Adjustment').val(Number(AdjustmentValue).toFixed(2));
  6105. $(".hdn_adjustment").val($('#txt_Adjustment').val());
  6106. $("#span_Adjustment").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(AdjustmentValue, 2));
  6107. $('.nettotal').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number(total) + AdjustmentValue), 2));
  6108. }
  6109. }
  6110. }
  6111. else {
  6112. $("#span_Adjustment").text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Number($('#txt_Adjustment').val()), 2));
  6113. $('.nettotal').text(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber((Number($('.nettotal').text()) + Number($('#txt_Adjustment').val())), 2));
  6114. }
  6115. }
  6116. update_discount_total() {
  6117. var item_total = Number($("#grosstotal").html()) - Number($("#totalItemDiscount").html());
  6118. var nettotal = Number($("#totalTax").text()) + Number(item_total);
  6119. var sub_dis_total = 0;
  6120. var prev_dis_total = 0;
  6121. $(".discount-row,.netdiscount-row").each(function () {
  6122. if ($(this).find(".percentage").val() != undefined) {
  6123. var ele = $(this);
  6124. var tt = prev_dis_total;
  6125. if (!isNaN(tt))
  6126. sub_dis_total += Number(tt);
  6127. var percent = ele.find(".percentage").val();
  6128. var value = ele.find(".fixedvalue").val();
  6129. var adjustment = 0;
  6130. if (percent == "")
  6131. percent = 0;
  6132. if (value == "")
  6133. value = 0;
  6134. var totaldiscount = 0;
  6135. var totalElement = $(this).find(".netdiscount-row-total");
  6136. if (totalElement.length != 0) {
  6137. totaldiscount = (Number(percent) * Number(nettotal - sub_dis_total) / 100) + Number(value) + Number(adjustment);
  6138. }
  6139. else
  6140. totaldiscount = (Number(percent) * Number(item_total - sub_dis_total) / 100) + Number(value) + Number(adjustment);
  6141. ele.find(".discount-row-total").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totaldiscount, 2));
  6142. ele.find(".netdiscount-row-total").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totaldiscount, 2));
  6143. prev_dis_total = totaldiscount;
  6144. }
  6145. });
  6146. InvoiceItem.Instance().update_total();
  6147. InvoiceItem.Instance().TotalAdjustment();
  6148. }
  6149. update_expense_total() {
  6150. var item_total = Number($("#grosstotal").html()) - Number($("#totalItemDiscount").html());
  6151. var nettotal = Number($("#totalTax").text()) + Number(item_total);
  6152. var sub_dis_total = 0;
  6153. var prev_dis_total = 0;
  6154. $(".expense-row").each(function () {
  6155. if ($(this).find(".exppercentage").val() != undefined) {
  6156. var ele = $(this);
  6157. var tt = prev_dis_total;
  6158. if (!isNaN(tt))
  6159. sub_dis_total += Number(tt);
  6160. var percent = ele.find(".exppercentage").val();
  6161. var value = ele.find(".expfixedvalue").val();
  6162. var adjustment = 0;
  6163. if (percent == "")
  6164. percent = 0;
  6165. if (value == "")
  6166. value = 0;
  6167. var totalexpense = (Number(percent) * Number(nettotal - sub_dis_total) / 100) + Number(value) + Number(adjustment);
  6168. ele.find(".expense-row-total").html(Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(totalexpense, 2));
  6169. prev_dis_total = totalexpense;
  6170. }
  6171. });
  6172. InvoiceItem.Instance().update_total();
  6173. InvoiceItem.Instance().TotalAdjustment();
  6174. }
  6175. RefreshItemRowDetaisl(element) {
  6176. if (element.filter('.SplInvoiceItemRow').length > 0) {
  6177. Bizgaze.Apps.Transact.Controls.Invoices.SplitItem.Instance().update_Discount(element);
  6178. var row = InvoiceItem.Instance().SplitedInvoiceItemList.find(x => x.invoiceItemId == element.find(".hf_selectedInvoiceItemId").val());
  6179. if (row != undefined) {
  6180. row.assesableAdjustment = element.find('.hf_ItemAssesableAdjustmentVal').val();
  6181. row.TotalAmount = element.find(".hf_RowTotal").val();
  6182. }
  6183. Bizgaze.Apps.Transact.Controls.Invoices.SplitItem.Instance().updateQuantity();
  6184. InvoiceItem.Instance().update_total();
  6185. }
  6186. else {
  6187. InvoiceItem.Instance().update_total();
  6188. }
  6189. }
  6190. editInvItemTaxAllocs(invoiceItemId, taxGroupId, itemId, orderItemId, element) {
  6191. var prvs = InvoiceItem.Instance().invItemTaxAdjustmentList;
  6192. var obj = {
  6193. invoiceItemId: invoiceItemId,
  6194. taxGroupId: taxGroupId,
  6195. itemId: itemId,
  6196. orderItemId: orderItemId,
  6197. element: element,
  6198. };
  6199. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/transact/components/invoices/invoiceitemtaxalloc.js", function () {
  6200. Unibase.Platform.Helpers.NavigationHelper.Instance().popup(obj, "", Bizgaze.Apps.Transact.Components.Invoices.InvoiceItemTaxAloc.Instance(), null, Unibase.Platform.Helpers.Size.Large);
  6201. });
  6202. InvoiceItem.Instance().invItemTaxAdjustmentList = prvs;
  6203. }
  6204. GetCustomerTurnOver() {
  6205. $(".txt_tcsadjustment").val("0");
  6206. $("#chk_tcsapplied").unbind();
  6207. $(".number_tcsamount").prop("disabled", true);
  6208. $(".div_tcsadjustment").addClass("floating-label-form-group-with-value");
  6209. $("#chk_tcsapplied").change(function () {
  6210. if ($(this).prop('checked') == true && InvoiceItem.Instance().EnableTenantTcs == false && ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4")) {
  6211. MessageHelper.Instance().showError("Please Submit TCS Declaration", $("#form-container-" + $("#hf_FormId").val()).find(".bizgaze_FormErrorMessages").attr('id'));
  6212. $("#hdnchk_tcsapplied").val("false");
  6213. $('#chk_tcsapplied').prop('checked', false);
  6214. }
  6215. else {
  6216. if ($('#chk_AutoAdjustment').prop("checked") == true) {
  6217. $("#txt_Adjustment").val(0);
  6218. $(".hdn_adjustment").val(0);
  6219. }
  6220. if ($(this).prop('checked') == true && $(".hdn_invoicetypeid").val() == "1") {
  6221. bootbox.confirm("Confirm if sale value is > 50,00,000 for this customer.In this current Financial Year.", function (result) {
  6222. if (result) {
  6223. $("#div_tcstaxrate").removeClass("hidden");
  6224. $(".div_tcsadjustment").removeClass("hidden");
  6225. $("#div_tcsamount").removeClass("hidden");
  6226. InvoiceItem.Instance().update_total();
  6227. InvoiceItem.Instance().TotalAdjustment();
  6228. }
  6229. else {
  6230. $("#div_tcstaxrate").addClass("hidden");
  6231. $(".div_tcsadjustment").addClass("hidden");
  6232. $("#div_tcsamount").addClass("hidden");
  6233. $('#chk_tcsapplied').prop('checked', false);
  6234. $("#hdnchk_tcsapplied").val("false");
  6235. InvoiceItem.Instance().update_total();
  6236. InvoiceItem.Instance().TotalAdjustment();
  6237. }
  6238. });
  6239. }
  6240. else if ($(this).prop('checked') == true) {
  6241. $("#div_tcstaxrate").removeClass("hidden");
  6242. $(".div_tcsadjustment").removeClass("hidden");
  6243. $("#div_tcsamount").removeClass("hidden");
  6244. InvoiceItem.Instance().update_total();
  6245. InvoiceItem.Instance().TotalAdjustment();
  6246. }
  6247. else {
  6248. $("#div_tcstaxrate").addClass("hidden");
  6249. $(".div_tcsadjustment").addClass("hidden");
  6250. $("#div_tcsamount").addClass("hidden");
  6251. InvoiceItem.Instance().update_total();
  6252. InvoiceItem.Instance().TotalAdjustment();
  6253. }
  6254. }
  6255. });
  6256. $(".txt_tcsadjustment").unbind();
  6257. $(".txt_tcsadjustment").blur(function () {
  6258. if ($('#chk_AutoAdjustment').prop("checked") == true) {
  6259. $("#txt_Adjustment").val(0);
  6260. $(".hdn_adjustment").val(0);
  6261. }
  6262. InvoiceItem.Instance().update_total();
  6263. InvoiceItem.Instance().TotalAdjustment();
  6264. });
  6265. $("#div_tcstaxrate").addClass("hidden");
  6266. $(".div_tcsadjustment").addClass("hidden");
  6267. $("#div_tcsamount").addClass("hidden");
  6268. $("#chk_tcsapplied").prop("checked", false);
  6269. $("#chk_tcsapplied").prop("disabled", false);
  6270. 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) {
  6271. if (response.result != null) {
  6272. $(".number_tcstaxrate").val(response.result.TaxRate);
  6273. if (response.result.TCSTaxCodeId != 0) {
  6274. $(".hdn_tcstaxcodeid").val(response.result.TCSTaxCodeId);
  6275. $(".hdn_tcstaxcodeaccountid").val(response.result.TCSTaxCodeAccountId);
  6276. $(".number_tcstaxrate").prop("disabled", true);
  6277. }
  6278. InvoiceItem.Instance().TurnOver = response.result.TurnOver;
  6279. InvoiceItem.Instance().ContactTcsEnable = response.result.Enable;
  6280. InvoiceItem.Instance().EnableTenantTcs = response.result.EnableTenantTcs;
  6281. InvoiceItem.Instance().PanAvailable = response.result.PanAvailable;
  6282. InvoiceItem.Instance().TaxRate = response.result.TaxRate;
  6283. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "2") {
  6284. if (InvoiceItem.Instance().ContactTcsEnable == true && InvoiceItem.Instance().EnableTenantTcs == true) {
  6285. $("#chk_tcsapplied").prop("checked", true);
  6286. $("#hdnchk_tcsapplied").val("true");
  6287. $("#div_tcstaxrate").removeClass("hidden");
  6288. $(".div_tcsadjustment").removeClass("hidden");
  6289. $("#div_tcsamount").removeClass("hidden");
  6290. $(".number_tcsamount").prop("disabled", true);
  6291. }
  6292. else if (InvoiceItem.Instance().TurnOver > 5000000 && $(".hdn_invoicetypeid").val() == "1") {
  6293. $("#chk_tcsapplied").prop("checked", true);
  6294. $("#chk_tcsapplied").prop("disabled", "disabled");
  6295. $("#hdnchk_tcsapplied").val("true");
  6296. $("#div_tcstaxrate").removeClass("hidden");
  6297. $(".div_tcsadjustment").removeClass("hidden");
  6298. $("#div_tcsamount").removeClass("hidden");
  6299. $(".number_tcsamount").prop("disabled", true);
  6300. }
  6301. }
  6302. else if ($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4" || $(".hdn_invoicetypeid").val() == "6" || $(".hdn_invoicetypeid").val() == "7") {
  6303. $("#chk_tcsapplied").prop("checked", false);
  6304. $("#hdnchk_tcsapplied").val("false");
  6305. $("#div_tcstaxrate").addClass("hidden");
  6306. $(".div_tcsadjustment").addClass("hidden");
  6307. $("#div_tcsamount").addClass("hidden");
  6308. }
  6309. if (($(".hdn_invoicetypeid").val() == "3" || $(".hdn_invoicetypeid").val() == "4") && $('#hfInv_RefInvoiceId').val() == 0 && $("#hf_AppSettingName").val() == "Create Return") {
  6310. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getInvoiceDetails(($(".hdn_invoicetypeid").val())).then(function (res) {
  6311. if (res.result != null && res.result != "") {
  6312. InvoiceItem.Instance().TaxRate = res.result.TcsTaxRate;
  6313. $(".number_tcstaxrate").val(res.result.TcsTaxRate);
  6314. $(".hdn_tcstaxcodeid").val(response.result.TcsTaxCodeId);
  6315. if (res.result.TcsTaxCodeId != 0) {
  6316. $(".number_tcstaxrate").prop("disabled", true);
  6317. }
  6318. $(".number_tcsamount").prop("disabled", true);
  6319. }
  6320. });
  6321. }
  6322. }
  6323. });
  6324. }
  6325. bindContactName() {
  6326. Unibase.Platform.Forms.Managers.TagManager.Instance().GetTagItemsByUserId(Unibase.Platform.Membership.Infos.Identity.getCurrentUser().userId).then(function (response) {
  6327. if (response.result.length == 1) {
  6328. InvoiceItem.instance.fileCacheHelper.loadJsFile("apps/crm/lobs/managers/lobmanager.js", function () {
  6329. Bizgaze.Apps.CRM.Lobs.Managers.LobManager.Instance().getLobByTagGroupId(response.result[0].TagGroupId).then(function (res) {
  6330. let LobId = res.result.LobId;
  6331. Bizgaze.Apps.CRM.Lobs.Managers.LobManager.Instance().getLobByLobId(LobId).then(function (result) {
  6332. if (result.result != null) {
  6333. if (result.result.DefaultContactId != 0) {
  6334. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/contacts/managers/contactmanager.js", function () {
  6335. Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getOrgContact(result.result.DefaultContactId).then(function (response) {
  6336. if (response.result != null) {
  6337. if (response.result.OrgContactName == null)
  6338. response.result.OrgContactName = "";
  6339. var _Name = new Option(response.result.OrgContactName, response.result.OrgContactId.toString(), false, false);
  6340. $(".txtAutoComplete_orgcontactid").append(_Name).trigger("change");
  6341. $(".hfAutoCompleteId_orgcontactid").val(response.result.OrgContactId);
  6342. InvoiceItem.Instance().LoadContactDetails();
  6343. }
  6344. });
  6345. });
  6346. }
  6347. }
  6348. });
  6349. });
  6350. });
  6351. }
  6352. });
  6353. }
  6354. GetDiscounts() {
  6355. if (($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3")) {
  6356. let contactid = Number($(".hdn_organizationid").val());
  6357. let invoicedate = moment($('.date_journaldate').val().toString(), "DD/MM/YYYY").format("YYYY-MM-DD");
  6358. if ($(".hdn_invoicetypeid").val() == "3")
  6359. invoicedate = moment($('.date_refdate').val().toString(), "DD/MM/YYYY").format("YYYY-MM-DD");
  6360. var ItemList = [];
  6361. $(".InvoiceItems").find(".item-row").each(function () {
  6362. if (!$(this).hasClass('SplitItem')) {
  6363. if ($(this).find(".selectedItemId").val() != undefined && $(this).find(".selectedItemId").val() != 0) {
  6364. var Quantity = Number($(this).find(".prodQuantity").val());
  6365. let ItemId = Number($(this).find(".selectedItemId").val());
  6366. ItemList.push({
  6367. ItemId: ItemId,
  6368. Quantity: Number(Quantity),
  6369. ContactId: contactid,
  6370. InvoiceDate: invoicedate
  6371. });
  6372. }
  6373. }
  6374. });
  6375. for (var i = 0; i < InvoiceItem.Instance().SplitedInvoiceItemList.length; i++) {
  6376. ItemList.push({
  6377. ItemId: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].itemId),
  6378. Quantity: Number(InvoiceItem.Instance().SplitedInvoiceItemList[i].quantity),
  6379. ContactId: contactid,
  6380. InvoiceDate: invoicedate
  6381. });
  6382. }
  6383. Bizgaze.Apps.Transact.Managers.OfferManager.Instance().getdiscounts(ItemList).then(function (response) {
  6384. var data = response.result;
  6385. var InvItemId = 0;
  6386. var discription = "";
  6387. if ($(".netdiscount-row[style='pointer-events:none']").length == 0 && $(".hdn_invoicetypeid").val() == "3") {
  6388. InvoiceItem.Instance().isOfferChargeApplied = false;
  6389. if (data != null)
  6390. data.PayoutValue == 0;
  6391. }
  6392. $('.netdiscount-row').each(function () {
  6393. var invoiceitemid = $(this).find(".selectedInvoiceItemId").val();
  6394. 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()))) {
  6395. $(this).remove();
  6396. if (invoiceitemid != undefined || invoiceitemid != 0) {
  6397. InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
  6398. InvItemId = Number(invoiceitemid);
  6399. discription = $(this).find('.discountDesc').val().toString();
  6400. }
  6401. InvoiceItem.Instance().update_total();
  6402. InvoiceItem.Instance().TotalAdjustment();
  6403. }
  6404. });
  6405. if (data != null && data.PayoutValue == 0) {
  6406. if ($(".netdiscount-row[style='pointer-events:none']").length > 0) {
  6407. var invoiceitemid = $(".netdiscount-row[style='pointer-events:none']").find(".selectedInvoiceItemId").val();
  6408. $(".netdiscount-row[style='pointer-events:none']").remove();
  6409. if (invoiceitemid != undefined || invoiceitemid != 0) {
  6410. InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
  6411. InvItemId = Number(invoiceitemid);
  6412. $(".hdn_isofferchargeapplied").val('false');
  6413. }
  6414. InvoiceItem.Instance().update_total();
  6415. InvoiceItem.Instance().TotalAdjustment();
  6416. }
  6417. }
  6418. if ((data != null && data.PayoutValue > 0)) {
  6419. if ($(".netdiscount-row[style='pointer-events:none']").length > 0) {
  6420. var itemid = $(".netdiscount-row[style='pointer-events:none']").find(".selectedItemId").val();
  6421. if (data.ItemId != itemid) {
  6422. var invoiceitemid = $(".netdiscount-row[style='pointer-events:none']").find(".selectedInvoiceItemId").val();
  6423. $(".netdiscount-row[style='pointer-events:none']").remove();
  6424. if (invoiceitemid != undefined || invoiceitemid != 0) {
  6425. InvoiceItem.Instance().deleted_invoiceItems.push(Number(invoiceitemid));
  6426. InvItemId = Number(invoiceitemid);
  6427. }
  6428. InvoiceItem.Instance().update_total();
  6429. InvoiceItem.Instance().TotalAdjustment();
  6430. }
  6431. }
  6432. let Index = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().deleted_invoiceItems.findIndex(x => x == InvItemId);
  6433. if (Index != -1) {
  6434. Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance().deleted_invoiceItems.splice(Index, 1);
  6435. }
  6436. var itemRow = {
  6437. orderItemId: 0,
  6438. invoiceItemId: InvItemId,
  6439. itemName: data.ItemName,
  6440. itemId: data.ItemId,
  6441. itemSKU: '',
  6442. unitName: "",
  6443. packSize: 0,
  6444. packCount: 0,
  6445. packs: 0,
  6446. quantity: 0,
  6447. availPacks: 0,
  6448. availQty: 0,
  6449. listPrice: 0,
  6450. description: discription,
  6451. taxGroupName: "",
  6452. taxGroupId: 0,
  6453. isTaxInclusive: $("#hf_istaxinclusive").val(),
  6454. addlDiscountPercent: 0,
  6455. addlDiscountValue: data.PayoutValue,
  6456. creditNote: 0,
  6457. priceListId: 0,
  6458. batchId: 0,
  6459. unitPrice: 0,
  6460. invoiceallocations: null,
  6461. exciseInvoiceItem: null,
  6462. accountId: 0,
  6463. accountName: "",
  6464. walletId: 0,
  6465. Adjustment: 0,
  6466. IsFoc: false,
  6467. TariffNo: "",
  6468. exciseAmount: 0,
  6469. discountName: "",
  6470. discountId: 0,
  6471. refNo: "",
  6472. DiscountGroupId: 0,
  6473. DiscountGroupName: '',
  6474. RefInvoiceItemId: 0,
  6475. MrpId: 0,
  6476. taxAdjustment: 0,
  6477. assesableAdjustment: 0,
  6478. inventoryTypeId: 5,
  6479. dcItemId: 0,
  6480. TotalRowAmount: 0,
  6481. maxQty: 0,
  6482. OfferItemId: 0
  6483. };
  6484. InvoiceItem.instance.addDataRow(itemRow, false);
  6485. }
  6486. });
  6487. }
  6488. }
  6489. GetOnInvoiceDiscountItem(element) {
  6490. if ($(".hdn_invoicetypeid").val() == "1" || $(".hdn_invoicetypeid").val() == "3") {
  6491. var itemid = element.find('.selectedItemId').val();
  6492. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getItemById(Number(itemid)).then(function (response) {
  6493. var data = response.result;
  6494. let invoiceid = $(".hdn_invoiceid").val();
  6495. if (invoiceid == undefined || invoiceid == "null")
  6496. invoiceid = 0;
  6497. if (data != null && !data.Sellable && !data.Purchasable)
  6498. element.attr("style", "pointer-events:none");
  6499. if (invoiceid == "0")
  6500. element.addClass("OnInvoiceOfferItem");
  6501. });
  6502. }
  6503. }
  6504. IsCustomerIndustrial(LobId, OrganizationId) {
  6505. var url1 = "apis/v4/bizgaze/transact/invoice/checkisenablesalespipeline/invoicetype/" + $(".hdn_invoicetypeid").val() + "/lobid/" + LobId + "/organizationid/" + OrganizationId;
  6506. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getIsEnableSalesPipeline(url1).then(function (response) {
  6507. if (response.result == false) {
  6508. $(".section_Ebs").addClass("hidden");
  6509. }
  6510. else {
  6511. $(".section_Ebs").removeClass("hidden");
  6512. }
  6513. });
  6514. }
  6515. loadChangeTaxGroupAutoComplete() {
  6516. var hfTaxgroup = $("#hdn_changetaxgroup");
  6517. AutoCompleteHelper.getHelper().Create("#change_taxgroup", hfTaxgroup, _appsettings.server_url() + "/apis/v4/bizgaze/transact/tax/taxgroupautocomplete", function (result) {
  6518. });
  6519. }
  6520. ShowOrHideEInvoiceButton() {
  6521. let instance = Bizgaze.Apps.Transact.Controls.InvoiceItem.Instance();
  6522. var installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  6523. var invoiceid = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + installedAppId + "_invoiceid").Value);
  6524. instance.fileCacheHelper.loadJsFiles(["apps/transact/managers/einvoice/einvoicemanager.js"], function () {
  6525. Bizgaze.Apps.Transact.Managers.EInvoiceManager.Instance().geteinvoicebyinvoiceid(invoiceid).then(function (res) {
  6526. if (res.result != null) {
  6527. if (res.result.EInvoiceStatusId == 2 || res.result.AckNo == null)
  6528. $(".DetailSetting_" + installedAppId + "_e-Invoice").removeClass("hidden");
  6529. else
  6530. $(".DetailSetting_" + installedAppId + "_e-Invoice").addClass("hidden");
  6531. }
  6532. });
  6533. });
  6534. }
  6535. static Instance() {
  6536. if (this.instance === undefined) {
  6537. this.instance = new InvoiceItem();
  6538. }
  6539. return this.instance;
  6540. }
  6541. }
  6542. Controls.InvoiceItem = InvoiceItem;
  6543. })(Controls = Transact.Controls || (Transact.Controls = {}));
  6544. })(Transact = Apps.Transact || (Apps.Transact = {}));
  6545. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  6546. })(Bizgaze || (Bizgaze = {}));
  6547. var Bizgaze;
  6548. (function (Bizgaze) {
  6549. let Apps;
  6550. (function (Apps) {
  6551. let Transact;
  6552. (function (Transact) {
  6553. let Controls;
  6554. (function (Controls) {
  6555. class CustomerCreditHealth extends Unibase.Platform.Core.BaseComponent {
  6556. constructor() {
  6557. super(...arguments);
  6558. this.ContainerId = "";
  6559. this.PopUpContainerId = "";
  6560. }
  6561. init(formpropertyid, prop, callback) {
  6562. var instance = this;
  6563. instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId);
  6564. instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId);
  6565. }
  6566. loadControl(containerid, prop) {
  6567. let instance = this;
  6568. instance.ContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
  6569. let html = instance.getCustomerCreditHealth_html();
  6570. $("#" + containerid).html(html);
  6571. }
  6572. getCustomerCreditHealth_html() {
  6573. 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;">' +
  6574. '<div class="card-body" ><span class="d-block font-15 font-weight-500 text-dark">' +
  6575. '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>' +
  6576. '<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">' +
  6577. ' <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>' +
  6578. '</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">' +
  6579. '<span class="d-block font-15 font-weight-500 text-dark"> Over Due </span><div class="mt-10">' +
  6580. '<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>' +
  6581. '</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">' +
  6582. '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>' +
  6583. ' </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">' +
  6584. '<span class="d-block font-15 font-weight-500 text-dark"> Credits </span><div class="mt-10">' +
  6585. ' <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>' +
  6586. ' </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;">' +
  6587. ' <div class="card-body"><span class="d-block font-15 font-weight-500 text-dark"> Clearance</span>' +
  6588. ' <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>' +
  6589. ' </div></div></div></div></div>';
  6590. return html;
  6591. }
  6592. loadControlSettings(controlsettingjson, formpropertyid) {
  6593. return null;
  6594. }
  6595. loadPropertySettings(propertysettings, formpropertyid) {
  6596. return null;
  6597. }
  6598. bindEditFormDetails(formpropertyid, propval, DocPropertyName) {
  6599. return null;
  6600. }
  6601. getCreditHealth(OrgContactId, OrganizationId, Type) {
  6602. var instance = this;
  6603. instance.ContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
  6604. let ContactId = Number(OrganizationId == 0 ? OrgContactId : OrganizationId);
  6605. if (ContactId == 0) {
  6606. return;
  6607. }
  6608. instance.bindKPIEvents(ContactId, Type);
  6609. instance.getCCH_KPIDetails(OrgContactId, OrganizationId, Type);
  6610. }
  6611. bindKPIEvents(ContactId, Type) {
  6612. let instance = this;
  6613. let TypeName = "Sales";
  6614. if (Type.toLowerCase().indexOf("purchase") != -1) {
  6615. TypeName = "Purchase";
  6616. }
  6617. instance.fileCacheHelper.loadJsFile("apps/transact/controls/orders/credithealth.js", function () {
  6618. $("#" + instance.ContainerId).find("#div_Due").unbind().click(function () {
  6619. Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_Due_CCH_" + TypeName + "Orders").then(function (res) {
  6620. if (res.result != null && res.result != "") {
  6621. var filter = [];
  6622. filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 });
  6623. Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_Due_CCH_" + TypeName + "Orders", null, filter, null);
  6624. }
  6625. else {
  6626. instance.getKPIPopUp("Due", "div_Due");
  6627. instance.getInvoiceDetails(ContactId, "Due");
  6628. }
  6629. });
  6630. });
  6631. $("#" + instance.ContainerId).find('#div_OverDue').unbind().click(function () {
  6632. Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_OverDue_CCH_" + TypeName + "Orders").then(function (res) {
  6633. if (res.result != null && res.result != "") {
  6634. var filter = [];
  6635. filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 });
  6636. Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_OverDue_CCH_" + TypeName + "Orders", null, filter, null);
  6637. }
  6638. else {
  6639. instance.getKPIPopUp("Over Due", "div_Due");
  6640. instance.getInvoiceDetails(ContactId, "OverDue");
  6641. }
  6642. });
  6643. });
  6644. $("#" + instance.ContainerId).find("#div_Credits").unbind().click(function () {
  6645. Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_Credits_CCH_" + TypeName + "Orders").then(function (res) {
  6646. if (res.result != null && res.result != "") {
  6647. var filter = [];
  6648. filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 });
  6649. Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_Credits_CCH_" + TypeName + "Orders", null, filter, null);
  6650. }
  6651. else {
  6652. instance.getKPIPopUp("Credits", "div_Credit");
  6653. instance.getCreditNotesDetails(ContactId);
  6654. }
  6655. });
  6656. });
  6657. $("#" + instance.ContainerId).find("#div_Clearance").unbind().click(function () {
  6658. Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId("Bizgaze_Platform_Analytics_Reports_Clearance_CCH_Orders").then(function (res) {
  6659. if (res.result != null && res.result != "") {
  6660. var filter = [];
  6661. filter.push({ "Key": "organizationid", "Value": ContactId.toString(), ExpOp: 1 });
  6662. Unibase.Platform.Analytics.Components.ReportViewer.Instance().report_ViewAllByUniqueId("Bizgaze_Platform_Analytics_Reports_Clearance_CCH_Orders", null, filter, null);
  6663. }
  6664. else {
  6665. instance.getKPIPopUp("Clearance", "div_Clearance");
  6666. instance.getPaymentDetails(ContactId);
  6667. }
  6668. });
  6669. });
  6670. });
  6671. }
  6672. getKPIPopUp(WidgetTitle, CurrentDiv) {
  6673. let instance = this;
  6674. instance.PopUpContainerId = '_modal_bizgaze_popup_' + moment().unix();
  6675. instance.navigationHelper.popup(0, instance.PopUpContainerId, Bizgaze.Apps.Transact.Orders.CreditHealth.Instance(), null, Unibase.Platform.Helpers.Size.ExtraLarge);
  6676. $("#" + instance.PopUpContainerId).find("." + CurrentDiv).removeClass("hidden");
  6677. $("#" + instance.PopUpContainerId).find(".title_widget").text(WidgetTitle);
  6678. $("#" + instance.PopUpContainerId).find("#widget_list_container").empty();
  6679. }
  6680. noData() {
  6681. let instance = this;
  6682. $("#" + instance.PopUpContainerId).find(".header_list").html('<div class="alert alert-info">There is no Data</div>');
  6683. $("#" + instance.PopUpContainerId).find(".span_Listsearch_count").text("0");
  6684. $("#" + instance.PopUpContainerId).find(".header_list").removeClass("d-none");
  6685. }
  6686. getKPIData(ReportName, OrganizationId, ResultColName, elem) {
  6687. let instance = this;
  6688. let resultData = 0;
  6689. let ReportUniqueId = "Bizgaze_Platform_Analytics_Reports_" + ReportName;
  6690. let _numberHelper = Unibase.Core.Helpers.NumberHelper.Instance();
  6691. Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportByUniqueId(ReportUniqueId).then(function (res) {
  6692. if (res.result != null && res.result != "") {
  6693. var postData = {
  6694. "ReportId": res.result.ReportId,
  6695. "page": 1,
  6696. "pageSize": 20,
  6697. "Filter": [],
  6698. "FilterId": 0,
  6699. "InputParameters": [
  6700. {
  6701. "Key": "organizationid",
  6702. "Value": OrganizationId.toString(),
  6703. "ExpOp": 1
  6704. }
  6705. ],
  6706. "SearchTerm": null,
  6707. "DateFilter": null,
  6708. "DisplayModeTypeId": 1,
  6709. "FromDate": "",
  6710. "ToDate": "",
  6711. "IsPortletWidget": false,
  6712. "IsShowAll": false,
  6713. "SortColumn": ""
  6714. };
  6715. Unibase.Platform.Analytics.Managers.ReportManager.Instance().getReportInfo(postData).then(function (report_res) {
  6716. if (report_res.result != null) {
  6717. if (report_res.result.ReportJsonData.Result.Data != null && report_res.result.ReportJsonData.Result.Data != "") {
  6718. let val = JSON.parse(report_res.result.ReportJsonData.Result.Data);
  6719. resultData = _numberHelper.roundNumber(val[0][ResultColName].toString().replace(/,/g, ''), 2);
  6720. if (resultData != null && resultData != undefined) {
  6721. resultData = resultData.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
  6722. }
  6723. $("#" + instance.ContainerId).find("#" + elem).text(resultData);
  6724. }
  6725. }
  6726. if (resultData == 0) {
  6727. $("#" + instance.ContainerId).find("#" + elem).text("0.00");
  6728. }
  6729. });
  6730. }
  6731. });
  6732. }
  6733. getCCH_KPIDetails(OrgContactId, OrganizationId, Type) {
  6734. let instance = this;
  6735. let TypeName = "Sales";
  6736. let CreditLimit = 0;
  6737. let AvailLimit = 0;
  6738. let OverDue = 0;
  6739. let Due = 0;
  6740. let Credits = 0;
  6741. let ClearanceAmount = 0;
  6742. Bizgaze.Apps.Transact.Managers.OrderManager.Instance().getCustomerCreditHealth(OrgContactId, OrganizationId).then(function (response) {
  6743. let data = response.result;
  6744. let _numberHelper = Unibase.Core.Helpers.NumberHelper.Instance();
  6745. if (data != "" && data != null) {
  6746. CreditLimit = _numberHelper.roundNumber(data.CreditLimit, 2);
  6747. AvailLimit = _numberHelper.roundNumber(data.AvailLimit, 2);
  6748. OverDue = _numberHelper.roundNumber(data.OverDue, 2);
  6749. Due = _numberHelper.roundNumber(data.OutStandingAmount, 2);
  6750. Credits = _numberHelper.roundNumber(data.Credits, 2);
  6751. ClearanceAmount = _numberHelper.roundNumber(data.ClearanceAmount, 2);
  6752. $("#" + instance.ContainerId).find("#span_CreditLimit").text(CreditLimit);
  6753. $("#" + instance.ContainerId).find("#span_AvailLimit").text(AvailLimit);
  6754. $("#" + instance.ContainerId).find("#span_OverDue").text(OverDue);
  6755. $("#" + instance.ContainerId).find("#span_Due").text(Due);
  6756. $("#" + instance.ContainerId).find("#span_Credits").text(Credits);
  6757. $("#" + instance.ContainerId).find("#span_Clearance").text(ClearanceAmount);
  6758. }
  6759. if (Type.toLowerCase().indexOf("purchase") != -1) {
  6760. TypeName = "Purchase";
  6761. }
  6762. instance.getKPIData("CreditLimit_CCH_OrdersKPIWidget", OrganizationId, "creditlimit", "span_CreditLimit");
  6763. instance.getKPIData("AvailLimit_CCH_OrdersKPIWidget", OrganizationId, "availlimit", "span_AvailLimit");
  6764. instance.getKPIData("OverDue_CCH_" + TypeName + "OrdersKPIWidget", OrganizationId, "overdue", "span_OverDue");
  6765. instance.getKPIData("DueAmount_CCH_" + TypeName + "OrdersKPIWidget", OrganizationId, "outstandingamount", "span_Due");
  6766. instance.getKPIData("Credits_CCH_" + TypeName + "OrdersKPIWidget", OrganizationId, "credits", "span_Credits");
  6767. instance.getKPIData("ClearanceAmount_CCH_OrdersKPIWidget", OrganizationId, "clearanceamount", "span_Clearance");
  6768. });
  6769. }
  6770. getInvoiceDetails(ContactId, DueorOverDue) {
  6771. let instance = this;
  6772. let IsOverDue = false;
  6773. if (DueorOverDue == "OverDue") {
  6774. IsOverDue = true;
  6775. }
  6776. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getPendingSalesInvoicesByContactId(ContactId, IsOverDue).then(function (response) {
  6777. var PendingInvoices = response.result;
  6778. if (PendingInvoices == "") {
  6779. instance.noData();
  6780. }
  6781. else {
  6782. var CurrentDate = new Date(), IsExpired = false, html = '';
  6783. $("#" + instance.PopUpContainerId).find("#widget_list_container").html('<li class="list-group-item list-Report-Due hidden"></li>');
  6784. for (var i = 0; i < PendingInvoices.length; i++) {
  6785. var InvoiceItem = PendingInvoices[i];
  6786. var Amount = InvoiceItem.TotalAmount;
  6787. var DueDate = new Date(InvoiceItem.DueDate);
  6788. var PaidAmount = Number(InvoiceItem.PaidAmount);
  6789. var DueAmount = Number(InvoiceItem.TotalAmount) - Number(InvoiceItem.PaidAmount);
  6790. if (DueDate < CurrentDate) {
  6791. IsExpired = true;
  6792. }
  6793. 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>';
  6794. }
  6795. $("#" + instance.PopUpContainerId).find(".span_Listsearch_count").text(PendingInvoices.length);
  6796. if (DueorOverDue == "Due" || (DueorOverDue == "OverDue" && IsExpired == true)) {
  6797. $("#" + instance.PopUpContainerId).find(".list-Report-Due:last").after(html);
  6798. }
  6799. else {
  6800. instance.noData();
  6801. }
  6802. }
  6803. });
  6804. }
  6805. getPaymentDetails(ContactId) {
  6806. let instance = this;
  6807. Bizgaze.Apps.Transact.Managers.PaymentManager.Instance().getAllPendingPayments(ContactId).then(function (response) {
  6808. var PendingPayments = response.result;
  6809. if (PendingPayments == "") {
  6810. instance.noData();
  6811. }
  6812. else {
  6813. $("#" + instance.PopUpContainerId).find("#widget_list_container").html('<li class="list-group-item list-Report-Clearance hidden"></li>');
  6814. var html = '';
  6815. for (var i = 0; i < PendingPayments.length; i++) {
  6816. var PaymentItem = PendingPayments[i];
  6817. var CreatedDate = new Date(PaymentItem.CreatedDate);
  6818. var currdate = new Date();
  6819. var diff = new Date(currdate - CreatedDate);
  6820. var days = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(diff / 1000 / 60 / 60 / 24, 2);
  6821. 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>';
  6822. }
  6823. $("#" + instance.PopUpContainerId).find(".list-Report-Clearance:last").after(html);
  6824. $("#" + instance.PopUpContainerId).find(".span_Listsearch_count").text(PendingPayments.length);
  6825. }
  6826. });
  6827. }
  6828. getCreditNotesDetails(ContactId) {
  6829. var instance = this;
  6830. Bizgaze.Apps.Transact.Managers.InvoiceManager.Instance().getCreditNotesByContactId(ContactId).then(function (response) {
  6831. var CreditNotes = response.result;
  6832. if (CreditNotes.length != 0) {
  6833. $("#" + instance.PopUpContainerId).find("#widget_list_container").html('<li class="list-group-item list-Report-Credits hidden"></li>');
  6834. var html = '';
  6835. for (var i = 0; i < CreditNotes.length; i++) {
  6836. var CreditNoteItem = CreditNotes[i];
  6837. var ConsumedAmount = CreditNoteItem.PaidAmount;
  6838. var TotalAmount = CreditNoteItem.TotalAmount;
  6839. var RemainingCredit = Number(CreditNoteItem.TotalAmount) - Number(CreditNoteItem.PaidAmount);
  6840. 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>';
  6841. $("#" + instance.PopUpContainerId).find(".list-Report-Credits:last").after(html);
  6842. }
  6843. }
  6844. $("#" + instance.PopUpContainerId).find(".span_Listsearch_count").text(CreditNotes.length);
  6845. if (CreditNotes.length == 0 || CreditNotes == "") {
  6846. $("#" + instance.PopUpContainerId).find(".header_list").removeClass("d-md-block").addClass("d-none");
  6847. }
  6848. instance.getAdvancePayments(ContactId, CreditNotes.length);
  6849. });
  6850. }
  6851. getAdvancePayments(ContactId, CreditsCount) {
  6852. let instance = this;
  6853. Bizgaze.Apps.Transact.Managers.PaymentManager.Instance().getAdvancePaymentsByOrgId(ContactId).then(function (response) {
  6854. var AdvancePayments = response.result;
  6855. $("#" + 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>');
  6856. if (AdvancePayments != "") {
  6857. var advancepaymentcount = AdvancePayments.length;
  6858. $(".advacepayment_Listsearch_count").html(advancepaymentcount);
  6859. if (AdvancePayments.length == 0 && CreditsCount == 0) {
  6860. instance.noData();
  6861. $(".card-advancePayments").addClass("d-none");
  6862. }
  6863. for (var i = 0; i < AdvancePayments.length; i++) {
  6864. var AdvancePaymentItem = AdvancePayments[i];
  6865. var ConsumedAmount = AdvancePaymentItem.AdjustedAmount;
  6866. var TotalAmount = AdvancePaymentItem.TotalAmount;
  6867. var RemainingCredit = Number(AdvancePaymentItem.TotalAmount) - Number(AdvancePaymentItem.AdjustedAmount);
  6868. var ExpTextColor = "text-info";
  6869. 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>';
  6870. $("#" + instance.PopUpContainerId).find(".list-Report-Payments:last").after(html);
  6871. }
  6872. $("#" + instance.PopUpContainerId).find(".span_Listsearch_count").text(CreditsCount + AdvancePayments.length);
  6873. }
  6874. else {
  6875. instance.noData();
  6876. }
  6877. });
  6878. }
  6879. static Instance() {
  6880. if (this.instance === undefined) {
  6881. this.instance = new CustomerCreditHealth();
  6882. }
  6883. return this.instance;
  6884. }
  6885. }
  6886. Controls.CustomerCreditHealth = CustomerCreditHealth;
  6887. })(Controls = Transact.Controls || (Transact.Controls = {}));
  6888. })(Transact = Apps.Transact || (Apps.Transact = {}));
  6889. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  6890. })(Bizgaze || (Bizgaze = {}));