Table of Content
HAL Forum
procedure CopyRow (
record FromRecord,row FromRow,row ToRow)
Description:
Copies one matrix row to another
Parameters:
FromRecord The record from where to take the row
FromRow The row to copy from
ToRow The row that will receive the data
procedure GroupVIbyTAXCode(var record VIVc VIr)
begin
  record VIVc GrVIr;
  row VIVc VIrw,GrVIrw;
  Integer i,rwcnt,j,grrwcnt;
  Boolean foundf;
  val vatv,t1;
  
  rwcnt = MatRowCnt(VIr);
  for (i=0;i<rwcnt;i=i+1) begin
    MatRowGet(VIr,i,VIrw);
    if (VIrw.stp==kInvoiceRowTypeNormal) then begin
      foundf = false;
      grrwcnt = MatRowCnt(GrVIr);
      for (j=0;j<grrwcnt;j=j+1) begin
        MatRowGet(GrVIr,j,GrVIrw);
        if (VATType(GrVIrw.VATCode)==VATType(VIrw.VATCode)) then begin
          GrVIrw.qty = GrVIrw.qty + VIrw.qty;
          GrVIrw.Sum = GrVIrw.Sum + VIrw.Sum;
          MulVATIV(VIrw.VATCode,VIrw.Sum,vatv,t1,0,VIr.NoTAXonVAT);
          GrVIrw.VATVal = GrVIrw.VATVal + vatv;
          MatRowPut(GrVIr,j,GrVIrw);
          foundf = true;
          j = grrwcnt;
        end;
      end;
      if (!foundf) then begin
        CopyRow(VIr,VIrw,GrVIrw);
        MulVATIV(VIrw.VATCode,VIrw.Sum,vatv,t1,0,VIr.NoTAXonVAT);
        GrVIrw.VATVal = vatv;
        MatRowPut(GrVIr,grrwcnt,GrVIrw);
      end;
    end;
  end;
  
  rwcnt = MatRowCnt(VIr);
  for (i=0;i<rwcnt;i=i+1) begin
    MatRowDelete(VIr,0);
  end;
  
  rwcnt = MatRowCnt(GrVIr);
  for (i=0;i<rwcnt;i=i+1) begin
    MatRowGet(GrVIr,i,VIrw);
    MatRowPut(VIr,i,VIrw);
  end;  
  return;
end;
Related topics:
««