; zjisti, u kterych pohybu neni evidovane seriove cislo
; verze z 10.1.2003
; Autor: WinDUO Team

Name('Pohyby bez sériových čísel')
Designed('SKL_MAN#1')
Author('Winduo Team','EMail: winduo@winduo.cz','http://www.winduo.com','http://www.winduo.cz')
Descr('Zjistí pohyby na skladových kartách, u kterých není evidováno sériové číslo,','popřípadě nesouhlasí jejich počet');

WNSType(1);
NewWNS('NOSERNUM.WNS');

SetHeadColumn(0,TA_Left,14);
SetHeadColumn(1,TA_Right,5);
SetHeadColumn(2,TA_Left,30);
SetHeadOfHead('Skladové číslo\tSklad\tNázev');
SetColumn(0,TA_Center,4);
SetColumn(1,TA_Left,10);
SetColumn(2,TA_Left,10);
SetColumn(3,TA_Right,12);
SetColumn(4,TA_Right,12);
SetHead('P/V\tDoklad\tz Data\tPohyb\ts.č.');

DeclareRec('Sklad')
DeclareRec('KeySklad1')
DeclareRec('Pohyb')
DeclareRec('KeyPohyb2')
DeclareRec('PohybSeriovehoCisla')
DeclareRec('KeyPohybSeriovehoCisla3')
ClearKey(KeySklad1)
Pozice:LongInt
InitStatus(UsedKeys(KeySklad1))
Veta:LongInt
VetaP:LongInt
VetaSNM:LongInt
CelkemSN:Double
LocBo:Boolean
LocBo2:Boolean
ItsHead:Boolean
While(NextKey(KeySklad1,Veta))
  begin
    ReadRec(Sklad,Veta)
    if((Sklad.Flags2&$1=0) and (InFilter(Sklad)))
      begin
        ItsHead=False
        KeyPohyb2.Length=4
        KeyPohyb2.CisloMat=SwapL(Sklad.Cislo)
        LocBo=SearchKey(KeyPohyb2,VetaP)
        While((LocBo) and (KeyPohyb2.CisloMat=SwapL(Sklad.Cislo)))
          begin
            ReadRec(Pohyb,VetaP);
            KeyPohybSeriovehoCisla3.Length=4;
            KeyPohybSeriovehoCisla3.CisloPH=SwapL(Pohyb.Cislo)
            CelkemSN=0
            LocBo2=SearchKey(KeyPohybSeriovehoCisla3,VetaSNM)
            While((LocBo2) and (KeyPohybSeriovehoCisla3.CisloPH=SwapL(Pohyb.Cislo)))
              begin
                ReadRec(PohybSeriovehoCisla,VetaSNM);
                if(Pohyb.Vydaj=PohybSeriovehoCisla.Vydaj)
                  CelkemSN=CelkemSN+PohybSeriovehoCisla.Mnozstvi
                else
                  CelkemSN=CelkemSN-PohybSeriovehoCisla.Mnozstvi
                LocBo2=NextKey(KeyPohybSeriovehoCisla3,VetaSNM);
              end;
            if(RoundQuantity(CelkemSN-Pohyb.Mnozstvi)<>0)
              begin
                if(not ItsHead)
                  begin
                    AddComment('');
                    AddHeadLine(Sklad.Material,Str(Sklad.Sklad),Sklad.Nazev);
                    ItsHead=True
                  end
                if(Pohyb.Vydaj)
                  AddText('V\t')
                else
                  AddText('P\t')
                AddLine(Pohyb.Doklad,StrDate(Pohyb.Datum),StrNative(Pohyb.Mnozstvi,3),StrNative(CelkemSN,3));
              end
            LocBo=NextKey(KeyPohyb2,VetaP);
          end;
      end;
    Inc(Pozice)                  ; zvyseni citace zpracovanych vet
    SetStatus(Pozice)            ; nastaveni stavoveho prouzku
  end
END;


