Table of Content
HAL Forum
VOID CopyRecordLinks (
record AnyFrom,record AnyTo)
Description:
Copies the record links from one record to another.
Parameters:
AnyFrom Any record to copy from
AnyTo Any record to copy to
updating procedure CreateQTFromBUQT(record BUQTVc BUQTr)
begin
  record NotepadVc Noter;
  record QTVc QTr;
  record QTVc oldQTr;
  row QTVc QTrw;
  row BUQTVc BUQTrw;
  string 255 tstr;
  Integer i,rwcnt;
  Integer companynr;
  val fr,to1,to2,br1,br2;

  RecordNew(QTr);
  
  QTr.QTDate = BUQTr.TransDate;
  QTr.CustCode = BUQTr.CustCode;
  if (PasteCustInQT(QTr,QTr.CustCode,"",tstr,true)) then begin end;  
  GetBaseCurncy(1,tstr);
  QTr.CurncyCode = tstr;
  GetFullCurncyRate(QTr.CurncyCode,QTr.QTDate,fr,to1,to2,br1,br2);
  QTr.FrRate = fr;
  QTr.ToRateB1 = to1;
  QTr.ToRateB2 = to2;  
  QTr.BaseRate1 = br1;
  QTr.BaseRate2 = br2;  
  QTr.SalesMan = BUQTr.SalesMan;
  QTr.Sign = BUQTr.SalesMan;
  QTr.LangCode = BUQTr.LangCode;
  QTr.InvoiceToCode = "";
  QTr.Closed = 0;
  QTr.BuildOn = 0;
  QTr.PRCode = BUQTr.PRCode;
  QTr.Comment = BUQTr.Comment;
  QTr.PriceList = "";
  QTr.RebCode = "";
  QTr.Rejected = BUQTr.Rejected;
  QTr.RejectDate = BUQTr.RejectDate;
  QTr.Markup = BUQTr.Markup;
  QTr.BudTime = BUQTr.BudTime;
  QTr.SumTime = BUQTr.SumTime;
  QTr.BudOther = BUQTr.BudOther;
  QTr.SumOther = BUQTr.SumOther;
  QTr.BudStocked = BUQTr.BudStocked;
  QTr.SumStocked = BUQTr.SumStocked;
  QTr.BudMaterial = BUQTr.BudMaterial;
  QTr.SumMaterial = BUQTr.SumMaterial;
  rwcnt = MatRowCnt(BUQTr);
  for (i=0;i<rwcnt;i=i+1) begin
    MatRowGet(BUQTr,i,BUQTrw);
    ClearRow(QTr,QTrw,1);
    QTrw.ArtCode = BUQTrw.ArtCode;
    QTrw.Quant = BUQTrw.Qty;
    QTrw.Price = BUQTrw.Price;
    QTrw.Sum = BUQTrw.Sum;
    QTrw.vRebate = BUQTrw.Discount;
    GetItemSalesAcc(QTrw.ArtCode,QTr.ExportFlag,tstr);
    QTrw.SalesAcc = tstr;
    QTrw.Objects = BUQTrw.Objects;
    QTrw.BasePrice = blankval;
    QTrw.rowGP = blankval;
    GetItemVATCode(QTrw.ArtCode,QTr.ExportFlag,tstr,false);
    QTrw.VATCode = tstr;
    QTrw.Spec = BUQTrw.Comment;
    QTrw.Recepy = BUQTrw.Recepy;
    QTrw.EMCode = BUQTrw.EMCode;
    QTrw.Markup = BUQTrw.Markup;
    QTrw.TimeClass = BUQTrw.TimeClass;
    QTrw.InvAfter = BUQTrw.InvAfter;
    QTrw.Invoiced = BUQTrw.Invoiced;
    QTrw.InvDate = BUQTrw.InvDate;
    QTrw.ItemType = BUQTrw.ItemType;
    QTrw.RowType = BUQTrw.RowType;
    QTrw.BudType = BUQTrw.BudType;
    MatRowPut(QTr,i,QTrw);
  end;    
  QTSumup(QTr);
  QTr.SerNr = NextSerNr("QTVc",QTr.QTDate,-1,false,"");  
  oldQTr.SerNr = QTr.SerNr;
  if (ReadFirstMain(oldQTr,1,true)==false) then begin  
    if (RecordImportStore(QTr,false)) then begin end;
    CopyRecordLinks(BUQTr,QTr);
    
    RecordNew(Noter);  
    rwcnt = LineTextCnt(BUQTr);
    for (i=0;i<rwcnt;i=i+1) begin
      tstr = LineTextGet(BUQTr,i);
      LineTextPut(Noter,i,tstr);      
    end;  
    if (RecordStore(Noter,false)) then begin
      CreateRecordLink(Noter,CurrentCompany,QTr,CurrentCompany);  
      CreateRecordLink(QTr,CurrentCompany,Noter,CurrentCompany);  
    end;

    RecordNew(Noter);
    rwcnt = 0;
    LineTextPut(Noter,rwcnt,BUQTr.Text0);      
    rwcnt = rwcnt + 1;
    LineTextPut(Noter,rwcnt,BUQTr.Text1);      
    rwcnt = rwcnt + 1;
    LineTextPut(Noter,rwcnt,BUQTr.Text2);      
    rwcnt = rwcnt + 1;
    LineTextPut(Noter,rwcnt,BUQTr.Text3);      
    rwcnt = rwcnt + 1;
    LineTextPut(Noter,rwcnt,BUQTr.Text4);      
    rwcnt = rwcnt + 1;
    LineTextPut(Noter,rwcnt,BUQTr.Text5);      
    rwcnt = rwcnt + 1;
    LineTextPut(Noter,rwcnt,BUQTr.Text6);      
    rwcnt = rwcnt + 1;
    LineTextPut(Noter,rwcnt,BUQTr.Text7);      
    rwcnt = rwcnt + 1;
    LineTextPut(Noter,rwcnt,BUQTr.Text8);      
    rwcnt = rwcnt + 1;
    LineTextPut(Noter,rwcnt,BUQTr.Text9);
    rwcnt = rwcnt + 1;
    if (RecordStore(Noter,false)) then begin
      CreateRecordLink(Noter,CurrentCompany,QTr,CurrentCompany);  
      CreateRecordLink(QTr,CurrentCompany,Noter,CurrentCompany);  
    end;
  end;  
  return;
end;

Related topics:
««