"localhost:/firebird/data/ILICHEVSK2.FDB". Процедуры Previous topic Chapter index Next topic

FORWARDER_REBUILDREP

 

Входные параметры

Параметр

Тип

Описание

AORDERITEMID

INTEGER

 

AVTO

INTEGER

 

 

Выходные параметры

Параметр

Тип

Описание

REGDATE

DATE

 

ACTNUMBER

VARCHAR(10)

 

TRANSPORTNUMBER

VARCHAR(31)

 

INVOICENUMBER

VARCHAR(31)

 

STATIONFULLNAME

VARCHAR(128)

 

EXPORTACTID

INTEGER

 

INVOICENET

INTEGER

 

DEFICIT

INTEGER

 

NET

INTEGER

 

SUMWEIGHT

BIGINT

 

 

Описание

(Нет описания для процедуры FORWARDER_REBUILDREP)

 

Определение

CREATE PROCEDURE FORWARDER_REBUILDREP(
    AORDERITEMID INTEGER,
    AVTO INTEGER)
RETURNS (
    REGDATE DATE,
    ACTNUMBER VARCHAR(10),
    TRANSPORTNUMBER VARCHAR(31),
    INVOICENUMBER VARCHAR(31),
    STATIONFULLNAME VARCHAR(128),
    EXPORTACTID INTEGER,
    INVOICENET INTEGER,
    DEFICIT INTEGER,
    NET INTEGER,
    SUMWEIGHT BIGINT)
AS
BEGIN
  FOR
    select
      EAsec.RegDate,
      EAsec.ActNumber,
      case
        when ITTransport.TransportTypeID in (0,1) and :AVTO = 0
        then 'авто'
        else ITTransport.TransportNumber
      end TransportNumber,
      case
        when ITTransport.TransportTypeID in (0,1) and :AVTO = 0
        then ''
        else Invoices.InvoiceNumber
      end InvoiceNumber,
      Stations.StationFullName,
      EAsec.ExportActID,
      (coalesce(ITTransport.InvoiceNet, 0)),
      (coalesce(IT1.Net,0)),
      (coalesce(IT1.Net,0) - coalesce(ITTransport.InvoiceNet,0)) as Deficit,
      (case
         when IT1.InventoryID = EAI.InventoryID then EAI.Weight
       end) SumWeight
        from OrderLoadItems  OLI
          left join ExportActs EA on (OLI.OrderLoadItemID = EA.OrderItemID)
          left join ExportActs EAsec on (EA.ExportActParentID = EAsec.ExportActID)
          left join ExportActItems EAIth on (EAsec.ExportActID = EAIth.ExportActID
            and EAIth.Weight > 0 )
          left join ExportActItems EAI on (EA.ExportActID = EAI.ExportActID
           and EAI.parentitemid = EAIth.exportactitemid
           and EAI.OperationID = 17 and (EAI.Weight > 0))
          left join IT IT1 on (EAIth.InventoryID = IT1.InventoryID)
          left join ITTransport on (IT1.InventoryID = ITTransport.InventoryID)
          left join Invoices on (IT1.InvoiceID = Invoices.InvoiceID)
          left join Stations on (EAsec.StationID = Stations.StationID)
        where  OLI.OrderLoadItemID = :AOrderItemID
    INTO :REGDATE,
         :ACTNUMBER,
         :TRANSPORTNUMBER,
         :INVOICENUMBER,
         :STATIONFULLNAME,
         :EXPORTACTID,
         :INVOICENET,
         :NET,
         :DEFICIT,
         :SUMWEIGHT
  DO
  BEGIN
    SUSPEND;
  END
END

 

     Previous topic Chapter index Next topic