STAT ;Statistieken [ 05/21/2003 11:48 AM ] ; KLANT(KLNr,PRNr,Begin,Einde,Piece,Simul) ; Piece : 1 = Qty, 2 = #faktlijn, 3 = Omzet, 4 = Marge ; Simul : Leeg dan ALLEEN statistiek gegevens ; : 1 Dan kijken naar NIET OPNEMEN IN ANAL nakijken ; : 2 Dan kijken naar NIET OPNEMEN IN PRIJSLIJST nakijken ;Bij Simul moet Piece=1, dit is alleen Qty's New I,Cumul,Maand,Rec If $G(Simul),$P(^KSTKL(KLNr,PRNr,0),D,6+Simul) Quit "" If $G(Simul),$P(^KSTKL(KLNr,PRNr,0),D,9) Quit $P(^KSTKL(KLNr,PRNr,0),D,9) Set PRNr=$G(PRNr),Begin=$G(Begin),Einde=$G(Einde),Piece=$G(Piece) Set:'PRNr PRNr=0 Set:Begin="" Begin=0 Set:Einde="" Einde=DJ_"."_DM_" " Set:'Piece Piece="1,99" If Begin'=0,$E(Begin,$L(Begin))'=" " Set Begin=Begin_" " Set:$E(Einde,$L(Einde))'=" " Einde=Einde_" " Set Maand=0 Set:Begin'=0 Maand=$O(^KSTKL(KLNr,PRNr,Begin),-1) Set Cumul="" For Set Maand=$O(^KSTKL(KLNr,PRNr,Maand)) Quit:Maand=""!(Maand]Einde) Do .Set Rec=^KSTKL(KLNr,PRNr,Maand) .For I=1:1:$L(Rec,D) Set $P(Cumul,D,I)=$P(Cumul,D,I)+$P(Rec,D,I) Xecute "Set Cumul=$P(Cumul,D,"_Piece_")" Quit Cumul ; // Oproepen via : // w $$PROD^STAT(PRNr,0,"2009.03 ","2010.03 ",1) PROD(PRNr,KLNr,Begin,Einde,Piece,OokStockOverMoeder) New I,Cumul,Maand,Rec Set KLNr=$G(KLNr),Begin=$G(Begin),Einde=$G(Einde),Piece=$G(Piece) Set:'KLNr KLNr=0 Set:Begin="" Begin=0 Set:Einde="" Einde=DJ_"."_DM_" " Set:'Piece Piece="1,99" If Begin'=0,$E(Begin,$L(Begin))'=" " Set Begin=Begin_" " Set:$E(Einde,$L(Einde))'=" " Einde=Einde_" " Set Maand=0 Set:Begin'=0 Maand=$O(^KSTPR(PRNr,KLNr,Begin),-1) Set Cumul="" For Set Maand=$O(^KSTPR(PRNr,KLNr,Maand)) Quit:Maand=""!(Maand]Einde) Do .Set Rec=^KSTPR(PRNr,KLNr,Maand) .For I=1:1:$L(Rec,D) Set $P(Cumul,D,I)=$P(Cumul,D,I)+$P(Rec,D,I) If $G(OokStockOverMoeder) Do ; Ook de statistiek van de moeder (indien StockOverMoeder) mee tellen . New MPRNr,BSKey,BSRec,Faktor . Set MPRNr="" . For Set MPRNr=$O(^PRBS("IP",PRNr,MPRNr)) Quit:MPRNr="" Do . . Quit:'$$ISSTOVK^KAKA8(MPRNr) ; Geen moederproduct met StockOverKinderen . . Set BSKey="" . . For Set BSKey=$O(^PRBS("IP",PRNr,MPRNr,BSKey)) Quit:BSKey="" Do . . . Set BSRec=$G(^PRBS("BS",MPRNr,BSKey)) . . . Set Faktor=$P(BSRec,D,2) . . . Quit:'Faktor . . . Set Maand=0 . . . Set:Begin'=0 Maand=$O(^KSTPR(MPRNr,KLNr,Begin),-1) . . . For Set Maand=$O(^KSTPR(MPRNr,KLNr,Maand)) Quit:Maand=""!(Maand]Einde) Do . . . . Set Rec=^KSTPR(MPRNr,KLNr,Maand) . . . . Set $P(Cumul,D,1)=$P(Cumul,D,1)+($P(Rec,D,1)*Faktor) ; Alleen het aantal geen omzet of marge Xecute "Set Cumul=$P(Cumul,D,"_Piece_")" Quit Cumul AANK(PRNr,Begin,Einde) ; *********************** ; Niet gebruiken KSPW is niet goed ingevuld PV - 19-04-99 ; *********************** ; Volgens KSPW : Begin, Einde = 'JJJJWW' New I,Cumul,TLNr,Rec Set:$G(Begin)="" Begin=0 Set:$G(Einde)="" Einde=99999999 Set Wk=0 Set:Begin'=0 Wk=$O(^KSPW(PRNr,Begin),-1) Set Cumul="" Set TLNr="" For Set Wk=$O(^KSPW(PRNr,Wk)) Quit:Wk="" Quit:Wk["." Do .For Set TLNr=$O(^KSPW(PRNr,Wk,TLNr)) Quit:TLNr="" Do ..Set Rec=^KSPW(PRNr,Wk,TLNr) ..For I=1:1:2 Set $P(Cumul,D,I)=$P(Cumul,D,I)+$P(Rec,D,I) Quit Cumul HISTOGROUPBY(PRNr,Begin,Einde,Actie,Magazijn,arHist,GroupBy) ;Begin,Einde : $H formaat ;Actie : Zie RES(PRHIST,PI,BEPERK) ;Magazijn : M = Magazijn, W = Werkvloer, K = Stock over kind, Z = Zonderstock ;Cumul, Aantal oproep via .Local (byRef) New Key,I,Rec Set Begin=$G(Begin) Set Einde=$G(Einde,999999) Set:$G(Magazijn)="" Magazijn="M" Set Key="" Set Cumul="",Aantal="" For Set Key=$O(^PRHIST(PRNr,Key)) Quit:Key="" Do . Set Rec=^PRHIST(PRNr,Key) . Quit:+$P(Rec,"\")Einde . Quit:$P(Rec,"\",5)'=Magazijn . Quit:$P(Rec,"\",4)'=Actie . Set IdxDate = +$P(Rec,"\") . if $get(GroupBy) = "W" Set IdxDate=$$INTDATE^vhDTyp($$EXTDATE^vhDTyp($H,"W"),"W") . Set arHist(IdxDate)=$g(arHist(IdxDate))+$P(Rec,"\",2) Quit HISTO(PRNr,Begin,Einde,Actie,Magazijn,Cumul,Aantal) ;Begin,Einde : $H formaat ;Actie : Zie RES(PRHIST,PI,BEPERK) ;Magazijn : M = Magazijn, W = Werkvloer, K = Stock over kind, Z = Zonderstock ;Cumul, Aantal oproep via .Local (byRef) New Key,I,Rec Set Begin=$G(Begin) Set Einde=$G(Einde,999999) Set:$G(Magazijn)="" Magazijn="M" Set Key="" Set Cumul="",Aantal="" For Set Key=$O(^PRHIST(PRNr,Key)) Quit:Key="" Do . Set Rec=^PRHIST(PRNr,Key) . Quit:+$P(Rec,"\")Einde . Quit:$P(Rec,"\",5)'=Magazijn . Quit:$P(Rec,"\",4)'=Actie . ;W Rec, "->",Cumul,! . Set Cumul=Cumul+$P(Rec,"\",2) . Set Aantal=Aantal+1 Quit ; AKT New PRNr For Set PRNr=$$SELECT^PRODUKT6() Quit:'PRNr Do MODSTAT(PRNr) Quit ; DEAKT New PRNr For Set PRNr=$$SELECT^PRODUKT6() Quit:'PRNr Do MODSTAT(PRNr,1) Quit ; MODSTAT(PRNr,KodeAnal) New R,KLNr Set KodeAnal=+$G(KodeAnal),KodeAnal=$S('KodeAnal:"",1:1) Set KLNr=0 For Set KLNr=$O(^KSTPR(PRNr,KLNr)) Quit:'KLNr Do .Quit:'$D(^KSTKL(KLNr,PRNr)) .Set R=^KSTKL(KLNr,PRNr,0),$P(R,D,7)=KodeAnal .Set ^KSTKL(KLNr,PRNr,0)=R Quit ; BLD(KLNr,PRNr,Datum,Aantal,Prijs,Round,Munt,Pariteit,SpecPrs,Netto,Marge,LijstPr,Kom,RecupVp) New R,ProfFakt Set Datum=$G(Datum),Kom=$G(Kom),RecupVp=$G(RecupVp) Do:'$D(Prijs) .Set R=$$KLANTPR^KPRIJS(KLNr,PRNr),Prijs=$P(R,D),Round=$P(R,D,10) .Set Munt=$P(R,D,2),Pariteit=$P(R,D,9),SpecPrs="" .Set:'$D(Netto) Netto=$P(R,D,14)*Aantal .Set:'$D(Marge) Marge=$P(R,D,14)-$P(R,D,13)*Aantal .Set:'$D(LijstPr) LijstPr=$P(R,D,15) Do:RecupVp .Set R=$O(^KPR(PRNr,"J")) Set:$E(R)="J" R=^KPR(PRNr,R) Set ProfFakt=$P(R,D,34) .Set:ProfFakt'="F" (Prijs,Netto,Marge,LijstPr)=0,SpecPrs="" Do BLDCUST(KLNr,PRNr,Datum,Aantal,Prijs,Round,Munt,Pariteit,SpecPrs,Netto,Marge,LijstPr,Kom,RecupVp) Do BLDPROD(PRNr,KLNr,Datum,Aantal,Prijs,Round,Munt,Pariteit,SpecPrs,Netto,Marge,LijstPr,Kom,RecupVp) Quit ; BLDCUST(KLNr,PRNr,Datum,Aantal,Prijs,Round,Munt,Pariteit,SpecPrs,Netto,Marge,LijstPr,Kom,RecupVp) New R,Maand,ProfFakt Set Datum=$G(Datum,DT),Kom=$G(Kom),RecupVp=$G(RecupVp) Set:Datum="" Datum=DT Do:'$D(Prijs) .Set R=$$KLANTPR^KPRIJS(KLNr,PRNr),Prijs=$P(R,D),Round=$P(R,D,10) .Set Munt=$P(R,D,2),Pariteit=$P(R,D,9),SpecPrs="" .Set:'$D(Netto) Netto=$P(R,D,14)*Aantal .Set:'$D(Marge) Marge=$P(R,D,14)-$P(R,D,13)*Aantal .Set:'$D(LijstPr) LijstPr=$P(R,D,15) Do:RecupVp .Set R=$O(^KPR(PRNr,"J")) Set:$E(R)="J" R=^KPR(PRNr,R) Set ProfFakt=$P(R,D,34) .Set:ProfFakt'="F" (Prijs,Netto,Marge,LijstPr)=0,SpecPrs="" Set Maand=$$CONVDATE^vhDTyp(Datum,,"DM4")_" " For PRNr=PRNr,0 Do .Set R=$G(^KSTKL(KLNr,PRNr,0)) Set:R="" $P(R,D,26)=D .Set $P(R,D)=Datum,$P(R,D,2)=Prijs,$P(R,D,3)=Round .Set $P(R,D,4)=Munt,$P(R,D,5)=Pariteit,$P(R,D,6)=SpecPrs .Set ^KSTKL(KLNr,PRNr,0)=R .Set R=$G(^KSTKL(KLNr,PRNr,Maand)) Set:R="" $P(R,D,6)=D .Set $P(R,D)=$P(R,D)+Aantal,$P(R,D,2)=$P(R,D,2)+1 .Set $P(R,D,3)=$P(R,D,3)+Netto,$P(R,D,4)=$P(R,D,4)+Marge .Set:Kom $P(R,D,5)=$P(R,D,5)+Aantal Set $P(R,D,6)=$P(R,D,6)+(Aantal*LijstPr) .Set ^KSTKL(KLNr,PRNr,Maand)=R Quit ; BLDPROD(PRNr,KLNr,Datum,Aantal,Prijs,Round,Munt,Pariteit,SpecPrs,Netto,Marge,LijstPr,Kom,RecupVp) New R,Maand,ProfFakt Set Datum=$G(Datum,DT),Kom=$G(Kom),RecupVp=$G(RecupVp) Set:Datum="" Datum=DT Do:'$D(Prijs) .Set R=$$KLANTPR^KPRIJS(KLNr,PRNr),Prijs=$P(R,D),Round=$P(R,D,10) .Set Munt=$P(R,D,2),Pariteit=$P(R,D,9),SpecPrs="" .Set:'$D(Netto) Netto=$P(R,D,14)*Aantal .Set:'$D(Marge) Marge=$P(R,D,14)-$P(R,D,13)*Aantal .Set:'$D(LijstPr) LijstPr=$P(R,D,15) Do:RecupVp .Set R=$O(^KPR(PRNr,"J")) Set:$E(R)="J" R=^KPR(PRNr,R) Set ProfFakt=$P(R,D,34) .Set:ProfFakt'="F" (Prijs,Netto,Marge,LijstPr)=0,SpecPrs="" Set Maand=$$CONVDATE^vhDTyp(Datum,,"DM4")_" " For KLNr=KLNr,0 Do .Set R=$G(^KSTPR(PRNr,KLNr,0)) Set:R="" $P(R,D,26)=D .Set $P(R,D)=Datum,$P(R,D,2)=Prijs,$P(R,D,3)=Round .Set $P(R,D,4)=Munt,$P(R,D,5)=Pariteit,$P(R,D,6)=SpecPrs .Set ^KSTPR(PRNr,KLNr,0)=R .Set R=$G(^KSTPR(PRNr,KLNr,Maand)) Set:R="" $P(R,D,6)=D .Set $P(R,D)=$P(R,D)+Aantal,$P(R,D,2)=$P(R,D,2)+1 .Set $P(R,D,3)=$P(R,D,3)+Netto,$P(R,D,4)=$P(R,D,4)+Marge .Set:Kom $P(R,D,5)=$P(R,D,5)+Aantal Set $P(R,D,6)=$P(R,D,6)+(Aantal*LijstPr) .Set ^KSTPR(PRNr,KLNr,Maand)=R Quit ; ; Is een product recent (voor de eerste keer) aangekocht door de klant (reeds gekocht = 0, nieuw = 1) RecentGekocht(KLNr,PRNr) Quit '$D(^KSTKL(KLNr,PRNr)) ;