#include vhLib.Macro #include BL.EC.Common #include %occInclude ; Call by: Do Test^Flow.Offerte.LijnProductAfgeleid.tmpDev ;Test() [routine: zie lager] ; Maakt een GAData.Product object voor oLijn ; Returns GAProd or "" GAProductBuildTBX(oLijn,blTBox,arErrs) ; blTBox,arErrs als .locals doorgeven #define GetKenm(%v) oLijn.Kenmerken.GetAt(%v) If '$IsObject(blTBox) Do . Set blTBox=##class(BL.PR.GA.TandemBox).%New() . Do blTBox.Initialize($$$GetKenm("ItemDC"),$$$GetKenm("ItemDS")) ;If ($$$GetKenm("EXCLUDE")=1) Do Quit "" ;Else If $$$GetKenm("ItemSTDL")=$$$tbxCodeStdLade Do Quit $$$tbxCodeStdLade New Templ,dsID,lbDomLU,sDomVERW,sDomKLNr,KLNrProd,KLKorting,KLReductie,arKDtl,GAProd Set arErrs("TBX","BLD")=$$bapTemplateViaLadeKL(.Templ,.dsID) Quit:('$IsObject(Templ)) "" Kill arErrs("TBX","BLD") Do bapPrepareVariables Do bapPrepareProduct ; Instantiates GAProd Do bapKenmerkenToProduct ; Set basic input values Do blTBox.BWValuesToProduct(GAProd) Do blTBox.KMValuesToProduct(GAProd,"TBR") ; GAProd is now ready to be calculated. You should call the GAProd.CalcAll() method from outside this routine. Quit GAProd bapTemplateViaLadeKL(Templ,dsID) ; Templ,dsID als .local doorgeven New klID,lbTPs,TPCode,TemplateID Set Templ="" Set klID=$$$GetKenm("ItemKL") Set:(klID="BE") klID="BA" Set dsID=blTBox.DesignFromLadeKleur(klID) Quit:(dsID="") "Geen Design gevonden" ; Alleen "Standaard Design" toegelaten. Quit:($LG(blTBox.BTDep("TBDesign","TBDesignCode",dsID),1)'?1(1"S",1"B")) "Geen Standaard Design" Set lbTPs=blTBox.TPCodesFromDesign(dsID) Set TPCode=$LG(lbTPs,1) Quit:(TPCode="") "TemplateCode niet gevonden" Set TemplateID=$LG(##class(Prod.GAData.Template).IDsViaCode(TPCode),1) Quit:(TemplateID="") "TemplateID niet gevonden" Set Templ=##class(Prod.GAData.Template).%OpenId(TemplateID) Quit $$$OK bapPrepareVariables ;New OrdStdL ;Set OrdStdL="LoadMeNow" Set lbDomLU=##class(WS.TBX.Order).DomainLookUp($$$GetKenm("WebDomain"),$LB("VERW","KLNR")) Set sDomVERW=$LG(lbDomLU,1) Set sDomKLNr=$LG(lbDomLU,2) Set KLNrProd=+$S(sDomVERW'="VHEPN":sDomKLNr, 1:$$$GetKenm("KLNummer")) Set KLKorting=$$$GetKenm("KLKorting") ; (waarde in % uitgedrukt) Set KLReductie=$S(+KLKorting'=0:$J(1-(KLKorting/100),0,4), 1:1) Quit bapPrepareProduct Do oLijn.Kenmerken.SetAt(dsID,"ItemDS") Set blTBox.Qty=$$$GetKenm("AANT") Set GAProd=##class(Prod.GAData.Product).BuildFromTemplate(Templ.%Id()) ;d WL^vhDBG("Tijd voor Stap 3a "_$C(9)_" : "_$$ChronoStepFMT^vhLib) Do GAProd.TemplateTmpInit() Do GAProd.AutosFromTemplate(,"FILL") Do:(KLNrProd) GAProd.KlantSetObjectId(KLNrProd) Quit bapKenmerkenToProduct #define PL blTBox.LookUp(KM,"DIC") New KM,arKenm Do bapKenmToTempArray Do bapFBevestNML Do:('$D(GAProd.LookUp("PLItem"))) GAProd.BuildLookUp($LB("ICode")) ; "PLItem" is onderdeel van BuildLU("ICode") Set KM="" For Set KM=$O(arKenm(KM)) Quit:(KM="") Do:($L($G($$$PL))) GAProd.SetItemValByPL($$$PL,arKenm(KM)) Do GAProd.BuildLookUp($LB("PL")) Quit bapKenmToTempArray New DSCode,KFront,KRug Set DSCode=$S($L($$$GetKenm("ItemDS")):$LG(blTBox.BTDep("TBDesign","TBDesignCode",$$$GetKenm("ItemDS")),1), 1:"") Set KFront=$S($L($$$GetKenm("ItemRK")):$LG(blTBox.BTDep("TBRelingKleur","TBFrontKleur",$$$GetKenm("ItemRK")),1), 1:"") Set KRug =$S($L($$$GetKenm("ItemDS")):$LG(blTBox.BTDep("TBDesign","TBRugKleur",dsID),1), 1:"") Set arKenm("TBDesign")=$$$GetKenm("ItemDS") Set arKenm("TBDesignCode")=DSCode Set arKenm("LadeCode")=$$$GetKenm("ItemLT") Do bapBTItemsLadeCode($$$GetKenm("ItemLT")) Set arKenm("TBFBevestiging")=$$$GetKenm("ItemFB") Set arKenm("TBCBreedte")=$$$GetKenm("ItemCB") Set arKenm("TBWandDikte")=$$$GetKenm("ItemWD") Set arKenm("OpvullijstLi")=$S($$$GetKenm("ItemOPVL")["L":25, 1:0) Set arKenm("OpvullijstRe")=$S($$$GetKenm("ItemOPVL")["R":25, 1:0) Set arKenm("MinTolerantie")=blTBox.DFLMinTolerantie($$$GetKenm("ItemWD")) ; $S(+$$$GetKenm("ItemWD")=0:0, 1:1) Set arKenm("TBLadeDiepte")=$$$GetKenm("ItemLD") Set arKenm("TBDraagKracht")=$$$GetKenm("ItemDK") Set arKenm("TBBodemKleur")=$$$GetKenm("ItemKB") Set arKenm("TBRelingKleur")=$$$GetKenm("ItemRK") Set arKenm("TBFrontKleur")=KFront Set arKenm("TBLadeKleur")=$S($$$GetKenm("ItemKL")="BE":"BA", 1:$$$GetKenm("ItemKL")) Set arKenm("TBRugKleur")=KRug Set arKenm("TBBlumotion")=$$$GetKenm("ItemBM") Set arKenm("TBBoxSide")=$$$GetKenm("ItemBX") Set arKenm("TBBoxsideKleur")=$$$GetKenm("ItemKX") Set arKenm("TBStabilisator")=$$$GetKenm("ItemSB") Set arKenm("TBFrontSteun")=$S($$$GetKenm("ItemFS")="":"A", 1:$$$GetKenm("ItemFS")) Set arKenm("TBDwarsVerdeling")=$$$GetKenm("ItemDWV") Set arKenm("TBStalenRug")="Z" Set arKenm("TBSPZijkant")=$$$GetKenm("ItemSPZK") Set arKenm("TBMat")=$$$GetKenm("ItemASM") Set arKenm("OrgaluxProduct")=$$$GetKenm("ItemOLP") If ($L($$$GetKenm("ItemVPK"))) Do . Set arKenm("Verpakking")=$$$GetKenm("ItemVPK") Set:($L($$$GetKenm("ItemBGRP"))) arKenm("TBBinnenGreep")=$$$GetKenm("ItemBGRP") Set:('$L($$$GetKenm("ItemBGRP"))) arKenm("TBBinnenGreep")=$S($$$GetKenm("ItemLT")?1(1"D/Z",1"C/Z"):"H",1:"") Quit bapBTItemsLadeCode(LCodeID) ; Uit LadeCode volgen deze vijf properties: ; TBKlasse - TBGlijderType - TBLadeType - TBZijwand - TBRugHoogte New LCode,Key,TBVal Set LCode=##class(Prod.GAMeta.BT.LadeCode).%OpenId(LCodeID) Quit:('LCode) Set Key="" For Set TBVal=LCode.TBKenm.GetNext(.Key) Quit:(Key="") Do . Set arKenm(Key)=TBVal Set LCode="" ; Do LCode.%Close() Quit bapFBevestNML ; FrontBevestiging Niet MeeLeveren bij Lade (niet Binnenlade) ZONDER FB ! If (arKenm("TBFBevestiging")="Z")&&(arKenm("TBLadeType")'="B") Do . Set arKenm("TBFBevestiging")="S" . Set arKenm("NMFBevestiging")=1 Quit /* nfwProductFromWSLijn(WSLn,i) ; Returns Prod (kan zowel ORef als string value zijn) ; Maakt een GAData.Product object voor WSLn If (WSLn.Exclude=1) Do Quit "" ;Else If WSLn.ItemSTDL=$$$tbxCodeStdLade Do Quit $$$tbxCodeStdLade ; ... Quit Prod bfwCalcProductsInit ;New i,Prod,arValidPR,Som,SomAant,WSLn,OrdStdL,arWSStdL,KLReductie,KLKorting ; defined in bfwCalcWSLijnen() Set OrdStdL="LoadMeNow" Set KLNrProd=+$S(sDomVERW'="VHEPN":sDomKLNr, 1:WS.KLNummer) Set KLKorting=WS.KLKorting ; (waarde in % uitgedrukt) Set KLReductie=$S(+KLKorting'=0:$J(1-(KLKorting/100),0,4), 1:1) Set (Som,SomAant)=0 Quit bfwCalcProduct(Prod,i) ;Set SomAant=SomAant+WSLn.Qty Kill arValidPR If Prod=$$$tbxCodeStdLade Do . Do bfwCalcProdStdL ; all params are globally known Else If $IsObject(Prod) Do . Do bfwCalcProdViaItems Else Do . ; Nothing Merge arValidWS(i)=arValidPR(0) Quit */ ; Call by: Do Test^Flow.Offerte.LijnProductAfgeleid.tmpDev Test // WS.TBX.Order wordt omgezet in Flow.Offerte.Hoofding+Lijnen // Deze Flow.Offerte wordt opgeslagen en kan later gebruikt worden om te processen. Kill s:('$D(%ClientIP)) %ClientIP="192.168.1.97" New sc Do tstCreateOfferte(391) Quit tstCreateOfferte(WSOrdID) $$$blEDI Set oHfd=%blEDI.WSOrd2Offerte("",WSOrdID) If '$IsObject(oHfd) Do Quit . w "Offerte Hfd not created." ; Else w "Succesfully converted WSOrd to Off. Hoofding ID="_oHfd.%Id() Quit Test2 // Een WS.TBX.OrderLijn wordt omgezet in Flow.Offerte.Lijn --> LijnProductAfgeleidTBX // Op deze lijn wordt GenerateProduct() uitgevoerd, deze creëert het Afgeleid product en het Prod.product // en beiden worden bewaard. Kill New sc Set LnA=##class(Flow.Offerte.LijnProductAfgeleidTBX).NewFromWSOrderLn(391,2) w:('LnA) "No LijnProductAfgeleidTBX" Quit:('LnA) Set sc=LnA.GenerateProduct() w $$$LCVT($$ObjectArrayToLB^vhLib(LnA.Kenmerken)),!,! Do $system.OBJ.Dump(LnA) w !,! Quit NewFromWSOrderLn(WSOrder,LijnID) ; Parameters: WSOrder,LijnID Quit:($G(WSOrder)="") "x" If '$IsObject(WSOrder) Do . Set WSOrder=##class(WS.TBX.Order).%OpenId(WSOrder) Quit $$NewFromWSOrderObj(WSOrder,.LijnID) NewFromWSOrderObj(WSOrder,LijnID) #define SetKenmVal(%v,%k) LnA.Kenmerken.SetAt(%v,%k) Quit:('$IsObject(WSOrder)) "" New WSOrdID,WSLn,LnA Set WSOrdID=WSOrder.%Id() Set WSLn=WSOrder.Lijnen.GetAt(LijnID) Quit:('$IsObject(WSLn)) "" Set LnA=##class(Flow.Offerte.LijnProductAfgeleidTBX).%New() Do nfwProptFromWSOrder Do nfwProptFromWSLijn ; Fill Kenmerken array from WSLn Do nfwKenmFromWSOrder Do nfwKenmFromWSLijn Quit LnA nfwProptFromWSOrder Quit nfwProptFromWSLijn Set LnA.GenerischType=WSLn.GAMeta Set LnA.GenerischProduct="" ; TO DO : GenPRNr invullen Set LnA.Aantal=WSLn.Qty Quit nfwKenmFromWSOrder Do $$$SetKenmVal(WSOrder.mID,"ID") Do $$$SetKenmVal(WSOrder.Taal,"Taal") Do $$$SetKenmVal(WSOrder.BonType,"BonType") Do $$$SetKenmVal(WSOrder.LeverTijd,"LeverTijd") Do $$$SetKenmVal(WSOrder.Commissie,"Commissie") Do $$$SetKenmVal(WSOrder.IngaveTijdStip,"IngaveTijdStip") Do $$$SetKenmVal(WSOrder.KLNaam,"KLNaam") Do $$$SetKenmVal(WSOrder.KLNummer,"KLNummer") Do $$$SetKenmVal(WSOrder.KLStraatNrBus,"KLStraatNrBus") Do $$$SetKenmVal(WSOrder.KLPostNr,"KLPostNr") Do $$$SetKenmVal(WSOrder.KLWoonPlaats,"KLWoonPlaats") Do $$$SetKenmVal(WSOrder.KLTelefoon,"KLTelefoon") Do $$$SetKenmVal(WSOrder.KLFax,"KLFax") Do $$$SetKenmVal(WSOrder.KLEMail,"KLEMail") Do $$$SetKenmVal(WSOrder.TotPrijs,"TotPrijs") Do $$$SetKenmVal(WSOrder.TotAantal,"TotAantal") Do $$$SetKenmVal(WSOrder.KLPrijsKlasse,"KLPrijsKlasse") Do $$$SetKenmVal(WSOrder.KLKorting,"KLKorting") Do $$$SetKenmVal(WSOrder.KLBTWNr,"KLBTWNr") Do $$$SetKenmVal(WSOrder.SubmitTS,"SubmitTS") Do $$$SetKenmVal(WSOrder.WebDomain,"WebDomain") Quit nfwKenmFromWSLijn New Key Set WSLn.GAMeta="TBX" Do $$$SetKenmVal(WSLn.LijnNr,"LIJNNR") Do $$$SetKenmVal(WSLn.Qty,"AANT") Do $$$SetKenmVal(WSLn.GAMeta,"GAMETA") Do $$$SetKenmVal(WSLn.Exclude,"EXCLUDE") Do $$$SetKenmVal(WSLn.KostPrijs,"PRIJS") For Key="DS","LT","CB","WD","LD","DK","BM","BX","ASM","BGRP","SPZK","SB","OPVL","STDL","VPK","OLP" Do . Do $$$SetKenmVal($zobjproperty(WSLn,"Item"_Key),"Item"_Key) For Key="KL","KB","RK","KX","FB" Do . Do $$$SetKenmVal($zobjproperty(WSLn,"Item"_Key),"Item"_Key) Quit DbgAdd(s,v) Set sDbg=sDbg_s_"="_v_" ** " Quit TTrace(msg) s:('$D(%ClientIP)) %ClientIP="192.168.1.97" d WL^vhDBG("TBox:"_msg) Quit TTraceW(msg) d TTrace(.msg) ;w msg,! Quit