Товар под заказ

Материал из wiki.standart-n.ru
Перейти к: навигация, поиск

Инструкция пользователя

Выполнить в базе

ALTER TABLE DOCS ADD DOC_TYPE2 DM_ID;

INSERT INTO DOC_TYPES (ID, CAPTION, INSERTDT, BASE_TYPE, STATINI, REPORTS, VTYPE)
               VALUES (1001, 'Подготовка заказа покупателя (чек для кассы)', '2018-09-24 14:44:27', 2, '[main]
FixedAgent=-2', NULL, 2);


INSERT INTO REPORTS (ID, PARENT_ID, STATUS, REPORTTYPE, SORTING, CAPTION, PARAMS, WDICT_ID, DATA) VALUES (1000, 0, 0, 3, 1, 'Договор розничной купли-продажи', NULL, NULL, NULL);

SET TERM ^ ;

create or alter procedure PR_ORDER_CASTING (
    DOC_ID integer,
    SESSIONS_ID integer)
returns (
    NEW_DOC_ID integer,
    COMMENTS DM_TEXT)
as
declare variable WARE_ID DM_UUID_NULL;
declare variable QUANT DM_DOUBLE;
declare variable SNAME DM_TEXT;
declare variable PART_ID integer;
declare variable BCODE_IZG DM_TEXT;
begin
 NEW_DOC_ID = null;

  for select ware_id, quant, sname, bcode_izg from doc_detail_virtual dd where doc_id = :doc_id into :ware_id, :quant, :sname, :bcode_izg do
  begin
      select first 1 part_id from warebase w where (w.ware_id = :ware_id or bcode_izg = :bcode_izg) and w.realquant >= :quant order by part_id into :part_id;
      if (part_id is not null) then
        begin
         if (NEW_DOC_ID is null) then select doc_id from pr_newdoc(1001,-2,0,null,null,:SESSIONS_ID) into :NEW_DOC_ID;
         select  coalesce(MSG, 'OK') || ' - ' || :sname || ' в кол-ве ' || cast(round(:quant,2) as dm_text) from pr_rashodpart(:NEW_DOC_ID,:part_id,:quant,null,null,null,null,1) into :COMMENTS;
        end
      else
        COMMENTS = 'Позиция ' || :sname || ' не найдена на остатке в кол-ве ' || cast(round(:quant,2) as dm_text);

      part_id = null;

      suspend;
  end
end^

SET TERM ; ^

/* Following GRANT statements are generated automatically */

GRANT SELECT ON DOC_DETAIL_VIRTUAL TO PROCEDURE PR_ORDER_CASTING;
GRANT SELECT ON WAREBASE TO PROCEDURE PR_ORDER_CASTING;
GRANT EXECUTE ON PROCEDURE PR_NEWDOC TO PROCEDURE PR_ORDER_CASTING;
GRANT EXECUTE ON PROCEDURE PR_RASHODPART TO PROCEDURE PR_ORDER_CASTING;

/* Existing privileges on this procedure */

GRANT EXECUTE ON PROCEDURE PR_ORDER_CASTING TO SYSDBA;


SET TERM ^ ;

create or alter procedure PR_GET_ORDER_STATUS (
    DOC_ID integer,
    DOC_TYPE integer)
returns (
    STATUS DM_TEXT)
as
begin

  if (doc_type <> 19) then
  begin
   STATUS = '';
   suspend;
   exit;
  end

  -- с проведенным чеком "исполнен"
  if (exists(select id from docs d where d.doc_type = 3 and status = 1 and d.parent_id = :doc_id and doc_type2 is null)) Then
  begin
   STATUS = 'исполнен';
   suspend;
   exit;
  end

  -- с отложенным чеком "готов к выдаче"
  if (exists(select id from docs d where d.doc_type = 3 and status <> 1 and d.parent_id = :doc_id and doc_type2 is null)) Then
  begin
   STATUS = 'готов к выдаче';
   suspend;
   exit;
  end

  -- без чека "в работе"
  if (not exists(select id from docs d where d.doc_type = 3 and d.parent_id = :doc_id and doc_type2 is null)) Then
  begin
   STATUS = 'в работе';
   suspend;
   exit;
  end

end^

SET TERM ; ^

/* Following GRANT statements are generated automatically */

GRANT SELECT ON DOCS TO PROCEDURE PR_GET_ORDER_STATUS;

/* Existing privileges on this procedure */

GRANT EXECUTE ON PROCEDURE PR_GET_ORDER_STATUS TO SYSDBA;

поправить VW_DOCS

добавить поле 
  ORDER_STATUS
источник
  (select status from pr_get_order_status(docs.id, docs.doc_type))

вывести в сетку