Установка механизма деления через фасовку.
Материал из wiki.standart-n.ru
Версия от 19:23, 26 июня 2015; Константин Кузнецов (обсуждение | вклад)
Содержание
Вставляем новый атрибут Ratio.
INSERT INTO ATTRIBUTES (ATTR_SID, ATTR_LINKFIELDNAME, ATTR_TYPE, STATUS) VALUES ('RATIO', 'barcode', 1, 0);
Вставляем новый тип документа "Фасовка"
INSERT INTO DOC_TYPES (ID, CAPTION, BASE_TYPE, STATINI, REPORTS, VTYPE) VALUES ((select max(id)+1 from doc_types), 'Фасовка', 3, '[main] FixedAgent=-2
[dbf] inipath=dbf.ini
[freereport] enabled=1 caption=Печать пакета документов report_id=103', NULL, 3);
Меняем Views
VW_DOC_DETAIL
RATIO, PRICE_RATIO
как
(select svalue from pr_getattribute('RATIO', p.barcode)), p.price/iif ((coalesce(cast((select first 1 svalue from pr_getattribute('RATIO', p.barcode)) as dm_id),1) > 0), abs(coalesce(cast((select first 1 svalue from pr_getattribute('RATIO', p.barcode)) as dm_id),1)), 1)
VW_DOC_DETAIL_ACTIVE
RATIO, REALQUANT_RATIO, PRICE_RATIO
как
(select svalue from pr_getattribute('RATIO', da.barcode)), iif ((coalesce(cast((select first 1 svalue from pr_getattribute('RATIO', da.barcode)) as dm_id),1) > 0), abs(coalesce(cast((select first 1 svalue from pr_getattribute('RATIO', da.barcode)) as dm_id),1)*quant), abs(quant)), price/iif ((coalesce(cast((select first 1 svalue from pr_getattribute('RATIO', da.barcode)) as dm_id),1) > 0), abs(coalesce(cast((select first 1 svalue from pr_getattribute('RATIO', da.barcode)) as dm_id),1)), 1)
VW_WAREBASE
RATIO, PRICE_RATIO
как
(select svalue from pr_getattribute('RATIO', wb.barcode)), price/iif ((coalesce(cast((select first 1 svalue from pr_getattribute('RATIO', wb.barcode)) as dm_id),1) > 0), abs(coalesce(cast((select first 1 svalue from pr_getattribute('RATIO', wb.barcode)) as dm_id),1)), 1)
VW_WAREBASE_KASSA
RATIO
как
cast(coalesce((select first 1 svalue from pr_getattribute('RATIO', w.barcode)), 1) as dm_id)
Меняем процедуры для распечатки штрихкодов
create or alter procedure OUT$PR_SHTRIH ( doc_id dm_id) returns ( id dm_id) as declare variable i dm_id; declare variable status dm_status; declare variable quant dm_id; declare variable base_type dm_id; declare variable ratio dm_id; begin select d.status, dt.base_type from docs d left join doc_types dt on dt.id=d.doc_type where d.id=:doc_id into :status, :base_type; if ((status=0) or (status=2)) then for select dd.id, (select cast(svalue as dm_id) from pr_getattribute('RATIO', dd.barcode)), coalesce((select svalue from pr_getattribute('barc_label_count', dd.barcode)), trunc(dd.quant), 1) from doc_detail_active dd where doc_id=:doc_id into :id,:ratio,:quant do begin if (ratio is not null) then quant = ratio*quant; i=1; while (i<=quant) do begin suspend; i=i+1; end end if ((status=1) and (base_type<>4)) then for select dd.id, (select cast(svalue as dm_id) from pr_getattribute('RATIO', p.barcode)), coalesce((select svalue from pr_getattribute('barc_label_count', w.name_id)), trunc(dd.quant), 1) from doc_detail dd inner join parts p on p.id = dd.part_id inner join wares w on w.id = p.ware_id where dd.doc_id=:doc_id into :id,:ratio,:quant do begin if (ratio is not null) then quant = ratio*quant; i=1; while (i<=quant) do begin suspend; i=i+1; end end if ((status=-1) and (base_type<>4)) then for select dd.id,coalesce((select svalue from pr_getattribute('barc_label_count', dd.name_id)), trunc(dd.quant), 1) from doc_detail_deleted dd where dd.doc_id=:doc_id into :id,:quant do begin i=1; while (i<=quant) do begin suspend; i=i+1; end end if (((status=1) or (status=-1)) and (base_type=4)) then for select dd.id,coalesce((select svalue from pr_getattribute('barc_label_count', dd.name_id)), trunc(dd.quant), 1) from doc_detail_virtual dd where doc_id=:doc_id into :id,:quant do begin i=1; while (i<=quant) do begin suspend; i=i+1; end end end
create or alter procedure OUT$PR_SHTRIH_WAREBASE ( part_id dm_id) returns ( id dm_id) as declare variable i dm_id; declare variable quant dm_id; declare variable ratio dm_id; begin for select dd.part_id,(select cast(svalue as dm_id) from pr_getattribute('RATIO', dd.barcode)), coalesce((select svalue from pr_getattribute('barc_label_count', dd.name_id)), trunc(dd.quant), 1) from warebase dd where dd.part_id=:part_id into :id,:ratio,:quant do begin if (ratio is not null) then quant = ratio*quant; i=1; while (i<=quant) do begin suspend; i=i+1; end end end
Меняем ТМС печати ценников из базы и активного документа
Заменяем во всех запросах (bar,bar_check,cenn,cenn_check)
price
на
price_ratio as price
Запрещаем редактирование кратности из остатков
В ТМС 214 редактирование поля вставляем запрет на редактирование ratio
if ((UPPERCASE(program_result.values['fieldname'])='QUANT') or (UPPERCASE(program_result.values['fieldname'])='PRICE') or (UPPERCASE(program_result.values['fieldname'])='PRICE_O') or (UPPERCASE(program_result.values['fieldname'])='PRICE_Z') or (UPPERCASE(program_result.values['fieldname'])='RATIO') or (UPPERCASE(program_result.values['fieldname'])='REALQUANT')) then begin showmessage('Редактирование поля запрещено!'); program_result.values['cancel']:='1'; end
По желанию пользователя выводим в сетке активного чека вместо стандартного количества Realquant_ratio, которое отображает количество в поделенных единицах