Procedura-GetNotRealizedExDiffs

Popis:
Vrátí ID a číslo dokladu všech závěrkových kurz.rozdílů k dokladům podle zadaného typu, období a zdrojové řady

Parametry:

NázevPopisDatový typ
Period_IDChar(10)
PDocQueue_IDChar(10)
DocumentTypeChar(2)

Návratové hodnoty:

NázevPopisDatový typ
IDChar(10)
OrdNumberInteger

Tělo:

BEGIN
  /* JCD */
  if (DocumentType = '12') then begin
    for
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, CustomsDeclarations B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Ostatní příjmy */
  if (DocumentType = '01') then begin
    for
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, OtherIncomes B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Ostatní výdaje */
  if (DocumentType = '02') then begin
    for
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, OtherExpenses B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Zálohové listy k faktuře přijaté */
  if (DocumentType = '11') then begin
    for 
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, ReceivedDInvoices B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Zálohové listy k faktuře vydané */
  if (DocumentType = '10') then begin
    for 
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, IssuedDInvoices B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Faktury vydané */
  if (DocumentType = '03') then begin
    for 
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, IssuedInvoices B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Faktury přijaté */
  if (DocumentType = '04') then begin
    for 
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, ReceivedInvoices B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Penalizační faktury */
  if (DocumentType = '17') then begin
    for 
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, PenaltyInvoices B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Dobropisy vydané */
  if (DocumentType = '60') then begin
    for
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, IssuedCreditNotes B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Dobropisy přijaté */
  if (DocumentType = '61') then begin
    for
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, ReceivedCreditNotes B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Danove zalohove listy vydane */
  if (DocumentType = '62') then begin
    for
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, VATIssuedDInvoices B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Dobropisy danovych zalohovych listu vydanych */
  if (DocumentType = '63') then begin
    for
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, VATIssuedDCreditNotes B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  
  /* Danove zalohove listy prijate */
  if (DocumentType = '64') then begin
    for
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, VATReceivedDInvoices B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
  /* Dobropisy danovych zalohovych listu vydanych */
  if (DocumentType = '65') then begin
    for
      select A.ID, A.OrdNumber
      from NotRealizedExDiffs A, VATReceivedDCreditNotes B
      where A.Period_ID = :Period_ID and A.PDocumentType = :DocumentType and
        A.PDocument_ID = B.ID and B.DocQueue_ID = :PDocQueue_ID
      into ID, OrdNumber
    do begin
      suspend;
    end
  end
END;

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