Table of Content
HAL Forum
function Val GetTurnover (
Record Cur,String salesexclvat,Date sd,Date ed)
Description:
Like GetBalance but in a time period
Parameters:
Cur single record from CUVc table
salesexclvat see NOTE in the example
sd start date
ed end date
Note:  The second argument could be: "salesinclvat", "salesexclvat", "quant", "transdebit", "transcredit",
 "grossprofit", "paidvalue", "priceexcldiscount", "price", "debquant", "credquant", "vesalesexclvat",
 "vesalesinclvat", "vepaidvalue",  

global
procedure CUHistRn(record RcVc RepSpec)
begin
  record CUVc CUr;
  String 255 tstr;
  String 20 frCu ,toCu,mykey;
  String 5 frCuCat;
  Boolean TrHs,testf,tefal;
  Date i;
  Val QtyCu,QtyCuCat,v,q,b,gp,p,fb,pb,fb1,pb1,p1;
  Val SumCu,SumCuCat,SumCub,SumCuCatb;
  Integer rw,m,rwc,k,keys;

  frCu = FirstInRange(RepSpec.f1,20); 
  frCuCat =  FirstInRange(RepSpec.f2,5);  
  rw = 1;
  StartReportJob(USetStr(9130));
  HT2Per(RepSpec.sStartDate,RepSpec.sEndDate,tstr);
  Header(rw, tstr, 1);
  rw = rw + 1;
  HTCusts(frCu,toCu,tstr);
  Header(rw, tstr, 0);
  HTCustCat(frCuCat,tstr);
  Header(rw, tstr, 1);
  rw = rw + 1;
  EndHeader;
  StartFormat(15);
  OutString(15,0,USetStr(9133),false);
  EndFormat;
  StartFormat(15);
  OutString(15,0,USetStr(9322),false);
  OutString(70,0,USetStr(9131),false);
  OutString(150,0,USetStr(9335),false);
  OutString(250,0,USetStr(3250),false);
  OutString(330,0,USetStr(3249),false);
  OutString(400,0,USetStr(9134),false);
  OutString(440,0,USetStr(9135),false);
  EndFormat;
  
  if (RepSpec.flags[0]==0) then begin//sort by code
    CUr.Code = frCu;
    mykey = "Code";
    keys = 1; 
  end;
  if (RepSpec.flags[0]==1)  begin//sort by Cat
    CUr.CustCat = frCuCat;
    CUr.Code = "";
    mykey = "Group";
    keys = 2; 
  end;

  SumCuCat = 0; QtyCuCat = 0; SumCuCatb = 0;
  Gray_Divider(20,460);  
  TrHs = true;
  while (LoopKey(mykey,CUr,keys,TrHs)) begin
     m=1; testf = true; SumCu = 0; QtyCu = 0; SumCub = 0; gp = 0; b=0;
     if nonblank(frCu) then begin
       if (CUr.Code <> frCu) then begin testf = false;  end;
     end;    
     if nonblank(frCuCat) then begin
       if (CUr.CustCat <> frCuCat) then begin testf = false; end; 
     end;      
     if (CUr.CUType==0) then begin testf = false; end;     
     if (testf == true) then begin
       q = GetTurnover(CUr,"paidvalue",RepSpec.sStartDate,RepSpec.sEndDate);
       v = GetTurnover(CUr,"salesinclvat",RepSpec.sStartDate,RepSpec.sEndDate);
       fb = GetBalance(CUr,"salesinclvat",RepSpec.d2);//fwd. bal. date
       fb1 = GetBalance(CUr,"paidvalue",RepSpec.d2);       
       fb = fb1 - fb;
       pb1 = GetBalance(CUr,"paidvalue",RepSpec.d1);
       pb = GetBalance(CUr,"salesinclvat",RepSpec.d1);
       pb = pb1 - pb;
       p1 =GetBalance(CUr,"paidvalue",RepSpec.sEndDate);
       p =GetBalance(CUr,"salesinclvat",RepSpec.sEndDate);
       p = p1 - p;
       b = fb;
       if (q <> 0 or v <> 0 or fb<>0 or pb<>0) then begin
         StartFormat(15);
         OutString(15,0,CUr.Code,false);
         OutString(70,0,CUr.CustCat,false);
         OutString(130,0,CUr.Name,false);
         EndFormat;
         Gray_Divider(20,460);
         StartFormat(15);
         OutString(140,0,USetStr(9136),true);
         OutVal(160,0,fb,M4Val,false);
         EndFormat;
         Black_Divider(20,220);
         StartFormat(15);
         for (i=RepSpec.sStartDate;i<=RepSpec.sEndDate;i=AddMonth(i,1)) begin
           q=GetTurnover(CUr,"paidvalue",i,i);
           if (m==1) then begin
 	...
Related topics:
««