Обновление процедур проведения документа - маркировка

Материал из wiki.standart-n.ru
Версия от 18:36, 18 марта 2021; Agk (обсуждение | вклад)

(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск
SET TERM ^ ;

create or alter procedure PR_UPDATEMARKBYPART (
    DOC_ID DM_ID,
    PART_ID DM_ID,
    ACTIVE_ID DM_ID)
as
begin
--Если не переоценка то
--Обновляем партию привязанную к SGTIN
  if ((select D.DOC_TYPE
       from DOCS D
       where D.ID = :DOC_ID) not in (8,58)) then
  begin
    update MARK_DETAIL
    set PART_ID = :PART_ID
    where DDA_ID = :ACTIVE_ID;
  end
  else
-- При переоценки вставляем записи в mark_detail
  begin
    insert into MARK_DETAIL (DOC_ID, PART_ID, MARK_DATA, QUANT, DOCNUM, DOC_DATE, DDA_ID, PLACE_ID_IN, PLACE_ID_OUT,
                             GTIN, SERIES_NUMBER, EXPIRATION_DATE, ACTIVEPOS, SERIA, KIZ, SSCC, ACCEPTED, MDLP_STATUS,
                             ERRORTEXT)
    select :DOC_ID, :PART_ID, MARK_DATA, -QUANT, DOCNUM, DOC_DATE, DDA_ID, PLACE_ID_IN, PLACE_ID_OUT, GTIN,
           SERIES_NUMBER, EXPIRATION_DATE, 1, SERIA, KIZ, SSCC, ACCEPTED, 1, ''
    from MARK_DETAIL MD
    where MD.DDA_ID = :ACTIVE_ID;
  end
  suspend;
end^

SET TERM ; ^

/* Следующие операторы GRANT сгенерированы автоматически */

GRANT SELECT ON DOCS TO PROCEDURE PR_UPDATEMARKBYPART;
GRANT SELECT,INSERT,UPDATE ON MARK_DETAIL TO PROCEDURE PR_UPDATEMARKBYPART;

/* Существующие привилегии на эту процедуру */

GRANT EXECUTE ON PROCEDURE PR_UPDATEMARKBYPART TO SYSDBA;

SET TERM ^ ;

create or alter procedure PR_DOC_DETAIL_INSERT (
    PARENT_ID bigint,
    DOC_ID bigint,
    PART_ID bigint,
    QUANT type of DM_DOUBLE,
    DISCOUNT double precision,
    SUMMA double precision,
    SUMMA_O double precision,
    PRICE numeric(15,4),
    SUM_NDSO numeric(15,4),
    SUM_NDSR DM_DOUBLE,
    NAC numeric(15,4),
    COMMITDATE type of DM_DATE,
    HUMAN_QUANT type of DM_TEXT,
    SUM_DSC type of DM_DOUBLE,
    DCARD type of DM_TEXT,
    ACTIVE_ID type of DM_ID,
    PART_TYPE DM_STATUS,
    MAKE_ID DM_ID_NULL = null,
    ACCEPTANCE DM_TEXT = null,
    AGENT_FIRST DM_TEXT = null,
    DATE_FIRST_PRIHOD DM_DATETIME = null,
    MARKING DM_ID_NULL = null,
    DATEPROD DM_DATE = null,
    GTIN_SUBJ DM_TEXT = null,
    ACCEPTTYPE DM_ID = null)
as
declare variable NEW_ID type of DM_ID;
begin
  new_id=gen_id(gen_doc_detail_id,1);
  insert into doc_detail
    (id,PARENT_ID,DOC_ID,PART_ID,QUANT,DISCOUNT,SUMMA,summa_o, sum_ndso,SUM_NDSR, price, nac, doc_commitdate, human_quant,SUM_DSC,dcard, part_type,make_id,
    acceptance,agent_first,date_first_prihod
/*26/06/2020 AVO Добавлены поля для маркировки*/
    ,MARKING,DATEPROD,GTIN_SUBJ,ACCEPTTYPE
/* end 26/06/2020 AVO*/
    )
    /* (PARENT_ID,DOC_ID,PART_ID,QUANT,DISCOUNT,SUMMA,summa_o) */
   values
    /* (:PARENT_ID,:DOC_ID,:PART_ID,:QUANT,:DISCOUNT,:SUMMA,:summa_o); */
    (:new_id,:PARENT_ID,:DOC_ID,:PART_ID,:QUANT,:DISCOUNT,:SUMMA,:summa_o, :sum_ndso,:SUM_NDSR, :price, :nac, :commitdate, :human_quant,:SUM_DSC,:dcard, :part_type,:make_id,
    :acceptance,:agent_first,:DATE_FIRST_PRIHOD
/*26/06/2020 AVO Добавлены поля для маркировки*/
    ,:MARKING,:DATEPROD,:GTIN_SUBJ,:ACCEPTTYPE
/* end 26/06/2020 AVO*/
    );
   execute procedure PR_DOC_DETAIL_ACTIVE_ONCOMMIT(:active_id,:new_id,:doc_id,:commitdate);
end^

SET TERM ; ^

/* Следующие операторы GRANT сгенерированы автоматически */

GRANT INSERT ON DOC_DETAIL TO PROCEDURE PR_DOC_DETAIL_INSERT;
GRANT EXECUTE ON PROCEDURE PR_DOC_DETAIL_ACTIVE_ONCOMMIT TO PROCEDURE PR_DOC_DETAIL_INSERT;

/* Существующие привилегии на эту процедуру */

GRANT EXECUTE ON PROCEDURE PR_DOC_DETAIL_INSERT TO PROCEDURE PR_DOC_PRIHOD_COMMIT_RECURSE;
GRANT EXECUTE ON PROCEDURE PR_DOC_DETAIL_INSERT TO PROCEDURE PR_DOC_RASHOD_COMMIT;
GRANT EXECUTE ON PROCEDURE PR_DOC_DETAIL_INSERT TO "PUBLIC";
GRANT EXECUTE ON PROCEDURE PR_DOC_DETAIL_INSERT TO STANDART;
GRANT EXECUTE ON PROCEDURE PR_DOC_DETAIL_INSERT TO SYSDBA;



SET TERM ^ ;

create or alter procedure PR_DOC_RASHOD_COMMIT (
    DOC_ID type of DM_ID,
    DBG type of DM_STATUS)
as
declare variable PARENT_ID type of DM_ID;
declare variable PART_ID type of DM_ID;
declare variable PRICE type of DM_DOUBLE;
declare variable QUANT type of DM_DOUBLE;
declare variable DISCOUNT type of DM_DOUBLE;
declare variable SUMMA type of DM_DOUBLE;
declare variable SUMMA_O type of DM_DOUBLE;
declare variable SUM_NDSO type of DM_DOUBLE;
declare variable SUM_NDSR DM_DOUBLE;
declare variable NAC type of DM_DOUBLE;
declare variable DOC_COMMITDATE type of DM_DATE;
declare variable HUMAN_QUANT type of DM_TEXT;
declare variable SUM_DSC type of DM_DOUBLE;
declare variable DCARD type of DM_TEXT;
declare variable ACTIVE_ID type of DM_ID;
declare variable PART_TYPE DM_STATUS;
declare variable BASE_AGENT_ID DM_ID;
declare variable MAKE_ID DM_ID_NULL;
declare variable ACCEPTTYPE DM_ID_NULL;
declare variable MARKING DM_ID_NULL;
declare variable DATEPROD DM_DATE;
declare variable GTIN_SUBJ DM_TEXT;
begin
  select cast(commitdate as date) from docs where id=:doc_id into :doc_commitdate;
  for select PARENT_ID,DOC_ID,PART_ID,PRICE,QUANT,DISCOUNT,SUMMA,summa_o, sum_ndso,SUM_NDSR, nac, human_quant, SUM_DSC, dcard, part_type, id, make_id
/*26/06/2020 AVO Добавлены поля для маркировки*/
   ,MARKING,DATEPROD,GTIN_SUBJ,ACCEPTTYPE
/* end 26/06/2020 AVO*/
  from doc_detail_active where doc_id=:doc_id
  into :PARENT_ID,:DOC_ID,:PART_ID,:PRICE,:QUANT,:DISCOUNT,:SUMMA,:summa_o, :sum_ndso,:SUM_NDSR, :nac, :human_quant, :SUM_DSC, :dcard, :part_type, :active_id, :make_id
/*26/06/2020 AVO Добавлены поля для маркировки*/
  ,:MARKING,:DATEPROD,:GTIN_SUBJ,:ACCEPTTYPE
/* end 26/06/2020 AVO*/
  do
   execute procedure PR_DOC_DETAIL_INSERT(:PARENT_ID,:DOC_ID,:PART_ID,QUANT,:DISCOUNT,:SUMMA,:summa_o, :price,:sum_ndso,:SUM_NDSR, :nac, :doc_commitdate, :human_quant, :SUM_DSC,:dcard,:active_id,:part_type,:make_id
   /*26/06/2020 AVO Добавлены поля для маркировки*/
   ,null, null, null, :MARKING,:DATEPROD,:GTIN_SUBJ,:ACCEPTTYPE
/* end 26/06/2020 AVO*/
    );
  execute procedure GM$PR_PRIHOD_DOC_TREB(:doc_id);
end^

SET TERM ; ^

/* Следующие операторы GRANT сгенерированы автоматически */

GRANT SELECT ON DOCS TO PROCEDURE PR_DOC_RASHOD_COMMIT;
GRANT SELECT ON DOC_DETAIL_ACTIVE TO PROCEDURE PR_DOC_RASHOD_COMMIT;
GRANT EXECUTE ON PROCEDURE PR_DOC_DETAIL_INSERT TO PROCEDURE PR_DOC_RASHOD_COMMIT;
GRANT EXECUTE ON PROCEDURE GM$PR_PRIHOD_DOC_TREB TO PROCEDURE PR_DOC_RASHOD_COMMIT;

/* Существующие привилегии на эту процедуру */

GRANT EXECUTE ON PROCEDURE PR_DOC_RASHOD_COMMIT TO PROCEDURE PR_DOC_COMMIT;
GRANT EXECUTE ON PROCEDURE PR_DOC_RASHOD_COMMIT TO "PUBLIC";
GRANT EXECUTE ON PROCEDURE PR_DOC_RASHOD_COMMIT TO STANDART;
GRANT EXECUTE ON PROCEDURE PR_DOC_RASHOD_COMMIT TO SYSDBA;