Procedura-RepBusProjects

Popis:
Projekty

Parametry:

NázevPopisDatový typ
AuditedChar(1)
DateFromFloat(0, 0)
DateToFloat(0, 0)
MaxNestingInteger
FromLevelInteger
FirmSelIDChar(10)
InBusTransactionSelIDChar(10)
InBusTransactionsWithChildsChar(1)
InDivisionSelIDChar(10)
InBusOrderSelIDChar(10)
InBusOrdersWithChildsChar(1)
InBusProjectSelIDChar(10)
InBusProjectsWithChildsChar(1)
SummarizeChar(1)
SortingInteger
IsRequestChar(1)
InDivisionsWithChildsChar(1)

Návratové hodnoty:

NázevPopisDatový typ
CompletePathVarChar(2000)
IncomesNumeric(15, 2)
ExpensesNumeric(15, 2)
BusProject_IDChar(10)
NestingInteger
ProfitNumeric(15, 2)

Závislosti:

NázevPopisTřída
RepBusProjects1Procedures

Tělo:

begin
  for
    select
      SUM(A.Incomes),
      SUM(A.Expenses),
      A.BusProject_ID,
      MAX(A.Nesting),
      SUM(A.Incomes)-SUM(A.Expenses),
      MAX(Z.Code),
      MAX(Z.Parent_ID),
      MAX(Z.Name)
    from
      RepBusProjects1(:Audited, :DateFrom, :DateTo, :FirmSelID,
        :InBusTransactionSelID, :InBusTransactionsWithChilds,
        :InDivisionSelID, :InBusOrderSelID, :InBusOrdersWithChilds,
        :InBusProjectSelID, :InBusProjectsWithChilds,
        :Summarize, :IsRequest, :InDivisionsWithChilds) A
      LEFT join BusProjects Z ON A.BusProject_ID = Z.ID
    where
      ( (:InBusProjectSelID = '') or
        (A.BusProject_ID in
          (
            SELECT Bx.ID FROM BusProjects Bx WHERE Bx.Hidden = 'N' AND
              ( (Bx.ID in (select OBJ_ID from SELDAT where SEL_ID = :InBusProjectSelID)) OR
                ((:InBusProjectsWithChilds in ('1', 'A')) and (Bx.ID in (select ID from SYS$BusProjects2 where Superior_ID in (select OBJ_ID from SELDAT where SEL_ID = :InBusProjectSelID)))))
          )
        )
      )
    group by A.BusProject_ID
    into Incomes, Expenses, BusProject_ID, Nesting, Profit, TempCode, TempParent_ID, TempName
  do begin
    if (Sorting = 0) then CompletePath = CAST(TempCode as CHAR(20)) || BusProject_ID;
    if (Sorting = 1) then CompletePath = CAST(TempName as CHAR(100)) || BusProject_ID;
    if (Sorting = 2) then CompletePath = '';                           /* Tridi se podle vystupniho parametru Profit */
    if (Sorting = 3) then CompletePath = CAST(TempCode as CHAR(20));
    if (Sorting = 4) then CompletePath = CAST(TempName as CHAR(100));
    i = 0;
    while (BusProject_ID is not null and TempParent_ID is not null and i < 100) do begin
      select Parent_ID, Code, ID, Name from BusProjects where ID = :TempParent_ID
        into TempParent_ID, TempCode, TempID, TempName;
      i = i + 1;
      if (Sorting = 0) then CompletePath = CAST(TempCode as CHAR(20)) || TempID || CompletePath;
      if (Sorting = 1) then CompletePath = CAST(TempName as CHAR(100)) || TempID || CompletePath;
     end
    Nesting = i;
    if ((FromLevel + MaxNesting) >= Nesting and FromLevel <= Nesting) then suspend;
   end
end;

Generated by ABRA Software a.s. 27.10.2021 16:34:17