Форум OlegON > Программы и оборудование для автоматизации торговли > Кассовые программы > УКМ-4

Как в шаблоне сделать чтобы товар с ценой и кол-вом были в одну строчку : УКМ-4

22.11.2024 9:06


04.12.2014 15:05
Добрый день, чтобы не создавать тему решил написать в этой.
Подскажите как в шаблоне сделать чтобы товар с ценой и кол-вом были в одну строчку.
спасибо. Редактирование receipt.lua приводит к ошибкам постоянным. то одно пропадет то другое.
04.12.2014 15:47
- Обновиться. Там для СП-402 заявлено такое

- Не обновляться, но взять из новой версии receipt.lua и адаптировать для себя соответствующий кусок

- М.б. кто-то выложит свое готовое

- Показать свои попытки доработки скриптов и к чему это привело
05.12.2014 07:41
Применять с осторожностью, сначала проверяйте на тестовом сервере. Это С+ делал нам доработку для изменения чека.


Код:
--переменная для сжатой печати
compresed_print = false;

function modificator_to_human(__modificator)
    local modif = "";
    local parsing_modificator = ukm.parse_client_modificator(__modificator);

    if parsing_modificator.prefix ~= "p" then
    if parsing_modificator.value:is_initialized() then
         modif = modif .. tostring(parsing_modificator.value:get());
    end

    if parsing_modificator.suffix == "%" then
         modif = modif .. "%";
    end
    else
      if parsing_modificator.pricelist_id:is_initialized() then
           modif = modif .. ukm.get_pricelist_name(parsing_modificator.pricelist_id:get())
      end
    end
    return modif;
end

function print_client(__header, __width)
    local text = "";
    if __header.client.__ok then
       text = text .. ukm.leftpad(" -", __width, " -") .. "\n";
       text = text .. ukm.adjustment("Фамилия:", __header.client.sur_name, __width, " ") .. "\n";
       text = text .. ukm.adjustment("Имя:", __header.client.name, __width, " ") .. "\n";
       if __header.client.patronymic:is_initialized() then
          text = text .. ukm.adjustment("Отчество:", __header.client.patronymic:get(), __width, " ") .. "\n";
       end
       if __header.client.enterprisename:is_initialized() then
          text = text .. ukm.adjustment("Название:", __header.client.enterprisename:get(), __width, " ") .. "\n";
       end
       if __header.client.inn:is_initialized() then
          text = text .. ukm.adjustment("ИНН:", __header.client.inn:get(), __width, " ") .. "\n";
       end
       if __header.client.passport:is_initialized() then
          text = text .. ukm.adjustment("Пасп.данные:", __header.client.passport:get(), __width, " ") .. "\n";
       end
    end
    return text;
end

function get_recnumb(__header)
   local recnumb = "";
   local receipt_type = __header:receipt_type();
   if receipt_type == ukm.header.sale then
        recnumb = "ПРД";
   elseif receipt_type == ukm.header.creturn then
        recnumb = "ВЗВ";
   elseif receipt_type == ukm.header.returnbyreceipt then
        recnumb = "ВЗВЧ";
   elseif receipt_type == ukm.header.pop then
        recnumb = "ПРД";
   elseif receipt_type == ukm.header.stockcount then
        recnumb = "ИНВ";
   elseif receipt_type == ukm.header.nonfiscal then
        recnumb = "НФИС";
   elseif receipt_type == ukm.header.returnbyreceiptnonfiscal then
        recnumb = "НФВЧ";
   elseif receipt_type == ukm.header.returnnonfiscal then
        recnumb = "НФВЗ";
   end
  return recnumb;
end

function print_item_to_printer(__item, __printer_type, __print_data)
    local printer = ukm.get_printer(__printer_type);
    if printer then
        local text = "";
        local width = printer:get_width();
        if __item.type == ukm.item.normal then
           text = text .. hw_command_normal_color;
        else
           text = text .. hw_command_alter_color;
        end

        if __item.remain:is_initialized() then
           if __item.remain:get():sign() == 0 then
             text = text .. ukm.leftpad("*", width, "*") .. "\n";
           end
        end
        local itemsign = " ";
        if __item.type == ukm.item.cancel then
            itemsign = "X";
        elseif __item.type == ukm.item.void then
            itemsign = "-";
        end

        local discount_item_all = "";

        if (__item:discount_amount() ~= ukm.currency(0)) then
            discount_item_all = tostring(__item:discount_amount() * ukm.currency(100) / __item.total);
            discount_item_all = " " .. discount_item_all .. "%";
        end

        local r = tostring(__item.totalquantity) .. "*" .. tostring(__item.price) .. "   " .. tostring(__item.total) .. discount_item_all .. itemsign;
        local l = __item.item .. " " .. __item.name;
        l = ukm.left(l, width - string.len(r) - 1) .. " ";
        text = text .. ukm.adjustment(l, r, width, " ") .. "\n";

-- Печать модификаторов
        if compresed_print == false then
           for i=0,__item.discounts:size()-1 do
             local discount = __item.discounts:at(i);
             local modificerot_item_iterator = ukm.map.int.string.iterator(discount.receipt_discount_item_properties);
             if modificerot_item_iterator:at(ukm.core.field_discount_modificator) ~= "" then
                    local modificator_item = modificerot_item_iterator:at(ukm.core.field_discount_modificator);
                    local human_modificator = modificator_to_human(modificator_item);
                    text = text .. ukm.adjustment(human_modificator, " ", width, " ") .. "\n";
             end
           end
         end

        text = text .. hw_command_normal_color;
        __print_data:add(text, ukm.printer_type_master());
    end
end

function print_link_header(__receiptlink, __print_data)
     local printer = ukm.get_printer(ukm.printer_type_master());
     if printer then
        local text = "";
        local width = printer:get_width();
        local header_t = "";
        local header_type = __receiptlink.receipt.header:receipt_type();
        if header_type == ukm.header.returnbyreceipt or header_type == ukm.header.returnbyreceiptnonfiscal then
           header_t = "ВОЗВРАТ ПО ЧЕКУ";
        elseif header_type == ukm.header.pop or header_type == ukm.header.nonfiscal then
           header_t = "ВОССТАНОВЛЕНИЕ ЧЕКА";
        elseif __receiptlink.receipt.header == ukm.header.stockcount then
           header_t = "ИНВЕНТАРИЗАЦИЯ";
        end

        text = text .. ukm.left(__receiptlink.receipt.link.headerlink.pos_name, width) .. "\n";

        if width <= 20 then
            text = text .. header_t .. "\n";
            text = text .. ukm.leftpad(ukm.ptime2str(__receiptlink.receipt.link.headerlink.date, "%d/%m/%Y %H:%M"),width," ") .. "\n";
        else
            text = text .. ukm.adjustment(header_t, ukm.ptime2str(__receiptlink.receipt.link.headerlink.date, "%d/%m/%Y %H:%M"), width, " ") .. "\n";
        end

        local recnumb = get_recnumb(__receiptlink.receipt.link.headerlink);
        if width <= 20 then
        text = text .. "ЧЕК:" .. tostring(__receiptlink.receipt.link.headerlink.pos) .. "." .. tostring(__receiptlink.receipt.link.headerlink.shiftopen.number) .. "." .. tostring(__receiptlink.receipt.link.headerlink.localnumber)  .. "\n";
        text = text .. ukm.adjustment(recnumb,"ТРН:" .. ukm.leftpad(tostring(__receiptlink.receipt.link.headerlink.globalnumber),12,"0"), width, " ") .. "\n";
        else
        text = text .. ukm.adjustment("ЧЕК:" .. tostring(__receiptlink.receipt.link.headerlink.pos) .. "." .. tostring(__receiptlink.receipt.link.headerlink.shiftopen.number) .. "." .. tostring(__receiptlink.receipt.link.headerlink.localnumber), recnumb .. " " .. "ТРН:" .. ukm.leftpad(tostring(__receiptlink.receipt.link.headerlink.globalnumber),12,"0"), width, " ") .. "\n";
        end
        text = text .. print_client(__receiptlink.receipt.link.headerlink, width);
        text = text .. ukm.leftpad("-", width, "-") .. "\n";

        __print_data:add(text, ukm.printer_type_master());
     end
end

function get_table_from_item(__item)
  local item_table = {};

  item_table.position = __item.position;
  item_table.type = __item.type;
  item_table.remain = __item.remain;
  item_table.item = __item.item;
  item_table.name = __item.name;
  item_table.measurement = __item.measurement;
  item_table.totalquantity = __item.totalquantity;
  item_table.price = __item.price;
  item_table.total = __item.total;
  item_table.properties = __item.properties;

  item_table.discounts = {};

  for i = 0,__item.discounts:size()-1 do
    local discount = __item.discounts:at(i);
    if item_table.discounts[discount.receiptdiscount.name] == nil then
      item_table.discounts[discount.receiptdiscount.name] = {};
      item_table.discounts[discount.receiptdiscount.name].name = discount.receiptdiscount.name;
      item_table.discounts[discount.receiptdiscount.name].increment = discount.increment;
    else
      item_table.discounts[discount.receiptdiscount.name].increment = item_table.discounts[discount.receiptdiscount.name].increment + discount.increment;
    end
  end

  local taxes = ukm.taxes(__item.receipt);
  taxes:create(__item);
  item_table.tax_item = {};
  for i=0, taxes.itemtaxes:size()-1 do
     local tax = taxes.itemtaxes:at(i);
     local tax_key = tostring(tax.taxid) .. "_" .. tax.percent;
     if item_table.tax_item[tax_key] == nil then
        item_table.tax_item[tax_key] = {};
        item_table.tax_item[tax_key].name = tax.name;
        item_table.tax_item[tax_key].percent = tax.percent;
        item_table.tax_item[tax_key].amount = tax.amount;
     end
  end
  return item_table;
end

function print_item(__item, __print_data)
  if compresed_print == false then
      print_item_to_printer(__item, ukm.printer_type_master(), __print_data);
  end
end

function print_discount(__discount, __print_data)
end

-- Печать сумм НеттоПроцесинг
function print_netto_subtotal(__normal_items)
    local printer = ukm.get_printer(ukm.printer_type_master());
    local width = printer:get_width();
    local text = "";
        
    local _amounts = {};
    
    for i = 0, __normal_items:size() - 1 do
        local item = __normal_items:at(i);
        local epts = item:get_epts();
        
        if epts:is_initialized() and epts:get() == 82 then
            local amount = ukm.currency(0);
            local tax = ukm.currency(0);
            
            if _amounts[item.item] ~= nil then
                amount = _amounts[item.item]["REALAMOUNT"];
                tax = _amounts[item.item]["TAXTOTAL"];
            end
            
            local temp_amount = ukm.currency(0);
            if temp_amount:from_string(find_item_property_value(item, "REALAMOUNT")) then
                amount = amount + temp_amount;
            end
            
            if temp_amount:from_string(find_item_property_value(item, "TAXTOTAL")) then
                tax = tax + temp_amount;
            end
            
            _amounts[item.item] = {NAME=item.name, REALAMOUNT=amount, TAXTOTAL=tax};
        end
    end

    for k,v in pairs(_amounts) do
        text = text .. ukm.adjustmentdouble("К ЗАЧИСЛЕНИЮ," .. string.upper(v["NAME"]), tostring(v["REALAMOUNT"]) .. " ", width, " ") .. "\n";
        text = text .. ukm.adjustmentdouble("КОМИССИЯ," .. string.upper(v["NAME"]), tostring(v["TAXTOTAL"]) .. " ", width, " ") .. "\n";
    end
    
    return text;
end

function print_hard_subtotal(__hard_subtotal, __print_data)
    if compresed_print == true then
      loc_item_table = {};
      loc_item_keys_table = {};
      local normal_items = __hard_subtotal.receipt.items:leavenormal();
      for j = 0, normal_items:size() - 1 do
          local i = get_table_from_item(normal_items:at(j));
          local key = i.item .. "_" .. tostring(i.price);
          if loc_item_table[key] == nil then
            table.insert(loc_item_keys_table,key);
            loc_item_table[key] = i;
          else
            loc_item_table[key].totalquantity = loc_item_table[key].totalquantity + i.totalquantity;
            loc_item_table[key].total = loc_item_table[key].total + i.total;

             for idk, idv in pairs(i.discounts) do
                 if loc_item_table[key].discounts[idk] == nil then
                     loc_item_table[key].discounts[idk] = {};
                     loc_item_table[key].discounts[idk].name = idv.name;
                     loc_item_table[key].discounts[idk].increment = idv.increment;
                 else
                     loc_item_table[key].discounts[idk].increment = loc_item_table[key].discounts[idk].increment + idv.increment;
                 end
             end

             for idk, idv in pairs(i.tax_item) do
                 if loc_item_table[key].tax_item[idk] == nil then
                     loc_item_table[key].tax_item[idk] = {};
                     loc_item_table[key].tax_item[idk].name = idv.name;
                     loc_item_table[key].tax_item[idk].percent = idv.name;
                     loc_item_table[key].tax_item[idk].amount = idv.amount;
                 else
                     loc_item_table[key].tax_item[idk].amount = loc_item_table[key].tax_item[idk].amount + idv.amount;
                 end
             end
          end
       end
--сортировка таблицей по ключу
       for i,v in ipairs(loc_item_keys_table) do
          print_item_to_printer(loc_item_table[v], ukm.printer_type_master(), __print_data);
       end
       loc_item_keys_table = {};
       loc_item_table = {};
    end

--печать подытога чека
    local printer = ukm.get_printer(ukm.printer_type_master());
    if printer then
        local text = "";
        local width = printer:get_width();
        text = text .. ukm.leftpad("-", width, "-") .. "\n";

    text = text .. ukm.adjustment("ВСЕГО:", tostring(__hard_subtotal.receipt.subtotal.amount + __hard_subtotal.receipt:receipt_discount_amount()) .. " ", width, " ") .. "\n";

--печать скидок чека

      for i=0, __hard_subtotal.receipt.discounts:size()-1 do
         local discount = __hard_subtotal.receipt.discounts:at(i);

         if __hard_subtotal.receipt.items:getdiscount(discount):is_initialized() and __hard_subtotal.receipt.items:getdiscount(discount):get():sign() ~= 0 then
            local c = "";

             if discount.card_number:is_initialized() then
                 c = discount.card_number:get();
             end

            local p = tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "%";

            local properties_iterator = ukm.map.int.string.iterator(discount.properties);

            if properties_iterator:at(ukm.core.field_discount_modificator) ~= "" then
                 p = properties_iterator:at(ukm.core.field_discount_modificator);
                 p = modificator_to_human(p);
            end

            text = text .. ukm.adjustment(discount.name .. " " .. c .. " " .. p, tostring(__hard_subtotal.receipt.items:getdiscount(discount):get()), width - 1, " ") .. "\n";
         end
      end

      text = text .. print_netto_subtotal(__hard_subtotal.receipt.items:leavenormal());
      
       if __hard_subtotal.receipt.type == ukm.core.goods_receipt then
          text = text .. "СУММА ПРОПИСЬЮ:" .. "\n";
          text = text .. "   " .. ukm.slice(ukm.num2txt(__hard_subtotal.receipt.subtotal.amount), width) .. "\n";
       end

       for i = 0, __hard_subtotal.receipt.discounts:size()-1 do
          local discount = __hard_subtotal.receipt.discounts:at(i);
          for j=0,discount.disc_info:size()-1 do
              local info = discount.disc_info:at(j);
              text = text .. "Ваши накопления:" .. "\n";
              text = text .. ukm.rightpad(tostring(info.amount) .. " - " ..info.name , width, " ") .. "\n";
          end
      end

      __print_data:add(text, ukm.printer_type_master());
  end
end

function print_receipt_payment(__payment, __print_data)
    local printer = ukm.get_printer(ukm.printer_type_master());
    if printer then
        local text = "";
        local width = printer:get_width();
        local paytype = "";
     if __payment.receipt.type ~= ukm.core.goods_receipt then
        if __payment.type == ukm.payment.void or __payment.type == ukm.payment.normal then
           local header_type = __payment.receipt.header:receipt_type();
           if header_type == ukm.header.nonfiscal or header_type == ukm.header.sale or header_type == ukm.header.pop then
              paytype = "ОПЛАТА";
           elseif header_type == ukm.header.returnbyreceiptnonfiscal or header_type == ukm.header.returnnonfiscal or header_type == ukm.header.creturn or header_type == ukm.header.returnbyreceipt then
              paytype = "ВОЗВРАТ";
           end
        elseif __payment.type == ukm.payment.change then
           paytype = "СДАЧА";
        end
        local npaytype = " ";
        if __payment.type == ukm.payment.cancel then
            npaytype = "X";
        elseif __payment.type == ukm.payment.void  or __payment.type == ukm.payment.change then
            npaytype = "-";
        end

        if string.len(paytype .. "," .. string.upper(__payment.paymentname) .. ":." .. ukm.leftpad(tostring(__payment.amountwithchange), 14 ,".") .. npaytype) < (width + 1) then
           text = text .. ukm.leftpad(paytype .. "," .. string.upper(__payment.paymentname) .. ":." .. ukm.leftpad(tostring(__payment.amountwithchange), 14 ,".") .. npaytype, width ," ")  .. "\n";
        else
           text = text .. ukm.rightpad(paytype .. "," .. string.upper(__payment.paymentname) .. ":.", width ,".")  .. "\n";
           text = text .. ukm.leftpad(tostring(__payment.amountwithchange) .. npaytype,width, ".") .. "\n";
        end
        __print_data:add(text, ukm.printer_type_master());
     end
    end
end

function print_receipt_close(__core, __print_data)
    local printer = ukm.get_printer(ukm.printer_type_master());
    if printer then
        local text = "";
        local width = printer:get_width();
        for i = 0, __core.discounts:size()-1 do
            local discount = __core.discounts:at(i);
            for j=0,discount.gifts:size()-1 do
                local gift = discount.gifts:at(j);
                text = text .. ukm.adjustment("Подарок", gift.itemname, width, ".") .. "\n";
            end
        end
    __print_data:add(text, ukm.printer_type_master());
    end
end

function print_receipt_open(__header, __print_data)
    local printer = ukm.get_printer(ukm.printer_type_master());
    if printer then
        local text = "";
        local width = printer:get_width();
        if __header.receipt.type == ukm.core.copy then
           text = text .. "*" .. ukm.center("К О П И Я   Ч Е К А",width-2," ") .. "*" .. "\n";
           text = text .. ukm.leftpad("*", width, "*") .. "\n";
        elseif __header.receipt.type == ukm.core.duplicate_ then
           text = text .. "*" .. ukm.center("Д У Б Л И К А Т   Ч Е К А",width-2," ") .. "*" .. "\n";
           text = text .. ukm.leftpad("*", width, "*") .. "\n";
        elseif __header.receipt.type == ukm.core.restore_ then
           text = text .. "*" .. ukm.center("Ч Е К   В О С С Т А Н О В Л Е Н",width-2," ") .. "*" .. "\n";
           text = text .. ukm.leftpad("*", width, "*") .. "\n";
        elseif __header.receipt.type == ukm.core.goods_receipt then
           text = text .. "*" .. ukm.center("Т О В А Р Н Ы Й   Ч Е К",width-2," ") .. "*" .. "\n";
           text = text .. ukm.leftpad("*", width, "*") .. "\n";
        end

-- касса-кассир-время
--        text = text .. ukm.left(__header.pos_name, width) .. "\n";
--        if width > 20 then
--           text = text .. ukm.adjustment(__header.login.name, ukm.ptime2str(__header.date, "%d/%m/%Y %H:%M"), width, " ") .. "\n";
--        else
--           text = text .. ukm.rightpad(__header.login.name, width, " ") .. "\n";
--           text = text .. ukm.leftpad(ukm.ptime2str(__header.date, "%d/%m/%Y %H:%M"),width," ") .. "\n";
--        end

        local recnumb = get_recnumb(__header);

        if width > 20 then
           text = text .. ukm.adjustment("ЧЕК:" .. tostring(__header.pos) .. "." .. tostring(__header.shiftopen.number) .. "." .. tostring(__header.localnumber), recnumb .. " " .. "ТРН:" .. ukm.leftpad(tostring(__header.globalnumber),12,"0"), width, " ") .. "\n";
        else
           text = text .. ukm.rightpad("ЧЕК:" .. tostring(__header.pos) .. "." .. tostring(__header.shiftopen.number) .. "." .. tostring(__header.localnumber), width, " ") .. "\n";
           text = text .. ukm.adjustment( recnumb , "ТРН:" ..ukm.leftpad(tostring(__header.globalnumber),12,"0"), width, " ") .. "\n";
        end

        text = text .. print_client(__header, width);
        text = text .. ukm.leftpad("-", width, "-") .. "\n";

        __print_data:add(text, ukm.printer_type_master());
    end
end
function print_receipt_footer(__footer, __print_data)
    local printer = ukm.get_printer(ukm.printer_type_master());
    if printer then
        local text = "";
        local width = printer:get_width();

        if (__footer.receipt.header.client.__ok) then
            if (__footer.receipt.header.client.saletype.type == ukm.saletype.sale_wholesale) then
             text = text .. ukm.center("Оптовая продажа", width, " ") .. "\n";
              if (__footer.receipt.header.client.saletype.invoice.__ok) then
                text = text .. ukm.adjustment("Счет-фактура №", __footer.receipt.header.client.saletype.invoice.number, width, " ") .. "\n";
              else
                text = text .. ukm.slice("Номер счета-фактуры необходимо узнать у администратора", width) .. "\n";
              end
            end
        end

        if __footer.result == ukm.footer.normal then
       text = text .. ukm.center("СПАСИБО ЗА ПОКУПКУ!",width," ") .. "\n";
        elseif __footer.result == ukm.footer.cancel then
           text = text .. hw_command_alter_color;
           text = text .. ukm.leftpad("*", width, "*") .. "\n";
           text = text .. "*" .. ukm.center("Ч Е К   А Н Н У Л И Р О В А Н",width-2," ") .. "*" .. "\n";
           text = text .. ukm.leftpad("*", width, "*") .. "\n";
           text = text .. hw_command_normal_color;
        elseif __footer.result == ukm.footer.push then
           text = text .. hw_command_alter_color;
           text = text .. ukm.leftpad("*", width, "*") .. "\n";
           text = text .. "*" .. ukm.center("Ч Е К   О Т Л О Ж Е Н",width-2," ") .. "*" .. "\n";
           text = text .. ukm.leftpad("*", width, "*") .. "\n";
           text = text .. hw_command_normal_color;
        elseif __footer.result == ukm.footer.broken then
           text = text .. hw_command_alter_color;
           text = text .. ukm.leftpad("*", width, "*") .. "\n";
           text = text .. "*" .. ukm.center("ВЫКЛЮЧЕНИЕ  ПИТАНИЯ",width-2," ") .. "*" .. "\n";

           text = text .. ukm.leftpad("*", width, "*") .. "\n";
           text = text .. hw_command_normal_color;
        end

       if __footer.receipt.type == ukm.core.goods_receipt then
          text = text .. " \n" .. " \n" .. "ПРОДАВЕЦ:_____________" .. " \n" .. " \n";
          text = text .. ukm.rightpad("М.П.",width," ") .. " \n" .. " \n" .. " \n";
       end
       
       __print_data:add(text, ukm.printer_type_master());
    end
end
Часовой пояс GMT +3, время: 09:06.

Форум на базе vBulletin®
Copyright © Jelsoft Enterprises Ltd.
В случае заимствования информации гипертекстовая индексируемая ссылка на Форум обязательна.