|
Namer |
Record |
i |
row number |
Namerw |
Row from record |
|
Global
Procedure PlanMn(record RcVc RepSpec)
begin
Integer wn, mwn;
Record RebVc REr;
Record RecVc RCr;
Record INVc INr;
Row RecVc RCrw;
Record TBBUVc PRr;
Row TBBUVc PRrw;
longInt i, desc, PreFin, PreBase, temp;
Val rwcnt, cant;
Date fecha;
String 20 texto;
//HalCallStack;
mwn = FindWindow("TBBUDClass");
GetWindowRecord(mwn,PRr);
REr.Code=RepSpec.f2;
if(ReadFirstMain(REr,1,true)) then begin
desc=REr.vra0;
end else begin
StopAlert("Discount not found");
end;
Rcr.Code=RepSpec.f4;
if(ReadFirstMain(RCr,1,true)) then begin
rwcnt=MatRowCnt(Rcr);
texto=Rcr.Comment;
end else begin
StopAlert("Quotes not found");
end;
for(i=0; i<(rwcnt+1); i=i+1) begin
if(i==0) then begin
MatRowGet(PRr,i,PRrw);
INr.Code=RepSpec.f1;
if(ReadFirstMain(INr,1,true)) then begin
PRrw.Comment=INr.Name;
end;
PRrw.stp=1;
PRrw.ArtCode=RepSpec.f1;
MatRowPut(PRr,i,PRrw);
end else begin
MatRowGet(PRr,i,PRrw);
INr.Code=RepSpec.f1;
if(ReadFirstMain(INr,1,true)) then begin
PreBase=INr.UPrice1;
end;
PreFin=PreBase - (PreBase*desc/100);
MatRowGet(RCr,i-1,RCrw);
PRrw.stp=1;
PRrw.Qty=1;
PRrw.Comment=RCrw.Comment;
PRrw.ArtCode=RCrw.Item;
PRrw.Price=PreFin/rwcnt;
PRrw.Sum=PreFin/rwcnt;
PRr.TotSum=PreFin;
if(i==1) then begin
PRrw.InvAfter=RepSpec.d1;
fecha=RepSpec.d1;
end else begin
switch (RepSpec.f3) begin
case "1": PRrw.InvAfter=AddMonth(fecha,1);
case "2": PRrw.InvAfter=AddMonth(fecha,2);
case "3": PRrw.InvAfter=AddMonth(fecha,3);
case "4": PRrw.InvAfter=AddMonth(fecha,4);
case "5": PRrw.InvAfter=AddMonth(fecha,6);
case "6": PRrw.InvAfter=AddMonth(fecha,12);
end;
end;
fecha=PRrw.InvAfter;
MatRowPut(PRr,i,PRrw);
end;
end;
PutWindowRecord(mwn,PRr);
return;
end;
|
««