Procedura-StoreBatchesFlowsByDates

Popis:
Vrátí stavy na šaržích/sér.č.

Parametry:

NázevPopisDatový typ
ADateFromFloat(0, 0)
ADateToFloat(0, 0)
AStoreSelIDChar(10)
AStoreCardSelIDChar(10)
AStoreBatchSelIDChar(10)
AFirmSelIDChar(10)
ADivisionSelIDChar(10)
ABusOrderSelIDChar(10)
ABusTransactionSelIDChar(10)
ABusProjectSelIDChar(10)
ADivisionsWithChildsChar(1)
ABusOrdersWithChildsChar(1)
ABusTransactionsWithChildsChar(1)
ABusProjectsWithChildsChar(1)
AStore_IDChar(10)
AStoreCard_IDChar(10)
AStoreBatch_IDChar(10)

Návratové hodnoty:

NázevPopisDatový typ
Store_IDChar(10)
StoreCard_IDChar(10)
StoreBatch_IDChar(10)
BegQuantityNumeric(15, 6)
QuantityNumeric(15, 6)
QuantityInNumeric(15, 6)
QuantityOutNumeric(15, 6)
QuantityTransNumeric(15, 6)
QuantityInvNumeric(15, 6)

Závislosti:

NázevPopisTřída
StoreBatchesFlowsByDatesSQLVrátí dynamicky sestavený dotaz pro získání stavu na šaržích/sér.č. (použije se v jiných stored procedurách)Procedures

Tělo:

begin
  -- Načteme SQL k získání stavů
  Select SQ from StoreBatchesFlowsByDatesSQL(
    :ADateFrom,
    :ADateTo,
    :AStoreSelID,
    :AStoreCardSelID,
    :AStoreBatchSelID,
    :AFirmSelID,
    :ADivisionSelID,
    :ABusOrderSelID,
    :ABusTransactionSelID,
    :ABusProjectSelID,
    :ADivisionsWithChilds,
    :ABusOrdersWithChilds, 
    :ABusTransactionsWithChilds,
    :ABusProjectsWithChilds,
    :AStore_ID,
    :AStoreCard_ID,
    :AStoreBatch_ID) into :SQLStatRun;
  -- vykonání SQL
  BegQuantity = 0;
  Quantity = 0;
  QuantityIn = 0;
  QuantityOut = 0;
  QuantityTrans = 0;
  QuantityInv = 0;
  StoreCard_ID = NULL;
  for EXECUTE STATEMENT SQLStatRun
  into mStore_ID, mStoreCard_ID, mStoreBatch_ID, mDocumentType, mQuantity do
  begin
    if ((mStore_ID <> Store_ID) or (mStoreCard_ID <> StoreCard_ID) or (mStoreBatch_ID <> StoreBatch_ID) ) then
    begin
      suspend;
      BegQuantity = 0;
      Quantity = 0;
      QuantityIn = 0;
      QuantityOut = 0;
      QuantityTrans = 0;
      QuantityInv = 0;
    end
    Store_ID = mStore_ID;
    StoreCard_ID = mStoreCard_ID;
    StoreBatch_ID = mStoreBatch_ID;
    /* zda se jedna o vydeje nebo prijmy */
    if (mDocumentType = 'BB' or mDocumentType = '22' or mDocumentType = '21' or 
      mDocumentType = '26' or mDocumentType = '27' or mDocumentType = '30' or 
      mDocumentType = '36' or mDocumentType = '38') 
    then
      mFlowSign = -1;
    else
      mFlowSign = 1;

    /* zda se jedna o pocatky nebo obraty */
    if (mDocumentType = '00' or mDocumentType = 'AA' or mDocumentType = 'BB') then
    begin
      BegQuantity = BegQuantity + mFlowSign * mQuantity;
    end
    else
    begin
      Quantity = Quantity + mFlowSign * mQuantity;
    end
    /* zda se jedna o prijmy */
    if (mDocumentType = '20' or mDocumentType = '28' or mDocumentType = '37' or mDocumentType = '39') then
    begin
      QuantityIn = QuantityIn + mFlowSign * mQuantity;
    end
    /* zda se jedna o výdeje  */
    if (mDocumentType = '21' or mDocumentType = '23' or mDocumentType = '27' or mDocumentType = '29'  or mDocumentType = '30' or
      mDocumentType = '36' or mDocumentType = '38') then
    begin
      QuantityOut = QuantityOut + mFlowSign * mQuantity;
    end
    /* zda se jedna o prevodky */
    if (mDocumentType = '22' or mDocumentType = '24') then
    begin
      QuantityTrans = QuantityTrans + mFlowSign * mQuantity;
    end
    /* zda se jedna o inventury */
    if (mDocumentType = '25' or mDocumentType = '26') then
    begin
      QuantityInv = QuantityInv + mFlowSign * mQuantity;
    end
  end
  if (mStoreCard_ID <> '') then
    suspend;
end

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