Входные параметры
Параметр  | Тип  | Описание  | 
|---|---|---|
DATE2  | 
    DATE  | 
    
  | 
  
PARTYID  | 
    INTEGER  | 
    
  | 
  
PARTYDATE  | 
    DATE  | 
    
  | 
  
FORMTYPE  | 
    INTEGER  | 
    
  | 
  
Выходные параметры
Параметр  | Тип  | Описание  | 
|---|---|---|
INCOMETYPE  | 
    VARCHAR(50)  | 
    
  | 
  
TTNS_INCOME  | 
    INTEGER  | 
    
  | 
  
REB_INCOME  | 
    INTEGER  | 
    
  | 
  
OUTCOME  | 
    INTEGER  | 
    
  | 
  
REB_OUTCOME  | 
    INTEGER  | 
    
  | 
  
INITIALREM  | 
    INTEGER  | 
    
  | 
  
STORING_DAK  | 
    INTEGER  | 
    
  | 
  
Описание
(Нет описания для процедуры ACC_FORMRN1)
Определение
CREATE PROCEDURE ACC_FORMRN1(
    DATE2 DATE,
    PARTYID INTEGER,
    PARTYDATE DATE,
    FORMTYPE INTEGER)
RETURNS (
    INCOMETYPE VARCHAR(50),
    TTNS_INCOME INTEGER,
    REB_INCOME INTEGER,
    OUTCOME INTEGER,
    REB_OUTCOME INTEGER,
    INITIALREM INTEGER,
    STORING_DAK INTEGER)
AS
begin
  incometype = 'Заставна закупка (згідно реєстру заставного зерна)';
  suspend;
  incometype = 'Закуплено за кред. та вл. кошти';
  suspend;
  incometype = 'Закуплено за регіона. ресурси';
  suspend;
  incometype = 'Зберігання на загальних умовах';
  select
    sum(it.net)
  from it
    join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
    left join quality on (it.samplerqualityid = quality.qualityid)
    left join crop on (quality.cropid = crop.cropid)
  where it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 45
    and ((it.storingid not in (2,7)) or (it.storingid is null))
    and ((crop.croptypeid in (1,6)) and (:formtype = 1))
         or ((crop.croptypeid =5) and (:formtype = 2))
   into
    :initialrem;
  select
    sum(it.net)
  from it
    join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
    left join quality on (it.samplerqualityid = quality.qualityid)
    left join crop on (quality.cropid = crop.cropid)
  where
    ((crop.croptypeid in (1,6)) and (:formtype = 1))
    or
    ((crop.croptypeid =5) and (:formtype = 2))
    and it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 1
    and ((it.storingid not in (2,7)) or (it.storingid is null))
   into
    :ttns_income;
  select sum(it.net) from it
    join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
    left join quality on (it.samplerqualityid = quality.qualityid)
    left join crop on (quality.cropid = crop.cropid)
  where
    ((crop.croptypeid in (1,6)) and (:formtype = 1))
    or
    ((crop.croptypeid =5) and (:formtype = 2))
    and it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 17
    and it.net > 0
    and ((it.storingid not in (2,7)) or (it.storingid is null))
   into
    :reb_income;
  select sum(it.net) * -1 from it
    join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
    left join quality on (it.samplerqualityid = quality.qualityid)
    left join crop on (quality.cropid = crop.cropid)
  where
    ((crop.croptypeid in (1,6)) and (:formtype = 1))
    or
    ((crop.croptypeid =5) and (:formtype = 2))
    and it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 17
    and it.net < 0
    and ((it.storingid not in (2,7)) or (it.storingid is null))
   into
    :reb_outcome;
  select sum(it.net) from it
    join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
    left join quality on (it.samplerqualityid = quality.qualityid)
    left join crop on (quality.cropid = crop.cropid)
  where
    ((crop.croptypeid in (1,6)) and (:formtype = 1))
    or
    ((crop.croptypeid =5) and (:formtype = 2))
    and it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 5
    and ((it.storingid not in (2,7)) or (it.storingid is null))
   into
    :outcome;
  select sum(it.net) from it
    join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
    left join quality on (it.samplerqualityid = quality.qualityid)
    left join crop on (quality.cropid = crop.cropid)
    left join clients on (it.ownerid = clients.clientid)
  where
    ((crop.croptypeid in (1,6)) and (:formtype = 1))
    or
    ((crop.croptypeid =5) and (:formtype = 2))
    and clients.clienttypeid = 5
    and it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 5
    and ((it.storingid not in (2,7)) or (it.storingid is null))
   into
    :storing_dak;
    initialrem = :initialrem / 1000;
    ttns_income = :ttns_income / 1000;
    reb_income = :reb_income / 1000;
    reb_outcome = :reb_outcome / 1000;
    outcome = :outcome / 1000;
    storing_dak = :storing_dak / 1000;
  suspend;
    storing_dak = 0;
    initialrem = 0;
    ttns_income = 0;
    reb_income = 0;
    reb_outcome = 0;
    outcome = 0;
   incometype = 'в т.ч. держресурси';
  suspend;
   incometype = '       держрезерв';
  suspend;
   incometype = 'Власне виробництво';
  select sum(it.net) from it
    join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
  left join quality on (it.samplerqualityid = quality.qualityid)
  left join crop on (quality.cropid = crop.cropid)
  where
    ((crop.croptypeid in (1,6)) and (:formtype = 1))
    or
    ((crop.croptypeid =5) and (:formtype = 2))
    and it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 45
    and it.storingid = 7
   into
    :initialrem;
  select sum(it.net) from it
  join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
  left join quality on (it.samplerqualityid = quality.qualityid)
  left join crop on (quality.cropid = crop.cropid)
  where
    ((crop.croptypeid in (1,6)) and (:formtype = 1))
    or
    ((crop.croptypeid =5) and (:formtype = 2))
    and it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 1
    and it.storingid = 7
   into
    :ttns_income;
  select sum(it.net) from it
  join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
  left join quality on (it.samplerqualityid = quality.qualityid)
  left join crop on (quality.cropid = crop.cropid)
  where
    ((crop.croptypeid in (1,6)) and (:formtype = 1))
    or
    ((crop.croptypeid =5) and (:formtype = 2))
    and it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 17
    and it.net > 0
    and it.storingid = 7
   into
    :reb_income;
  select sum(it.net) * -1 from it
  join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
  left join quality on (it.samplerqualityid = quality.qualityid)
  left join crop on (quality.cropid = crop.cropid)
  where
    ((crop.croptypeid in (1,6)) and (:formtype = 1))
    or
    ((crop.croptypeid =5) and (:formtype = 2))
    and it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 17
    and it.net < 0
    and it.storingid = 7
   into
    :reb_outcome;
  select sum(it.net) from it
    join GetWorkParties(:PARTYID,:PARTYDATE,null,null,null)
       on (IT.PartyID = GetWorkParties.PartyID)
    left join quality on (it.samplerqualityid = quality.qualityid)
  left join crop on (quality.cropid = crop.cropid)
  where
    ((crop.croptypeid in (1,6)) and (:formtype = 1))
    or
    ((crop.croptypeid =5) and (:formtype = 2))
    and it.regdate <= :date2
    and it.parentid >=0
    and it.state >=0
    and it.operationid = 5
    and it.storingid = 7
   into
    :outcome;
    initialrem = :initialrem / 1000;
    ttns_income = :ttns_income / 1000;
    reb_income = :reb_income / 1000;
    reb_outcome = :reb_outcome / 1000;
    outcome = :outcome / 1000;
  suspend;
    initialrem = 0;
    ttns_income = 0;
    reb_income = 0;
    reb_outcome = 0;
    outcome = 0;
    incometype = 'Давальницька пром. переробка';
  suspend;
end
         
         
         
       |