06.10.2011 11:09
Eugin_S
 
Подскажите, какое значение присвоить переменной c, чтобы вместо номера дисконтной карты печаталось имя клиента.

Вот мой код:
Код:
--печать скидок чека

      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
06.10.2011 11:31
whitewizard
 
Выгрузка случаем не с Супермага-2000 идёт?. Если, да то в нём изменить настройку.
06.10.2011 11:35
Mtirt
 
Какую настройку? Какая настройка вместо номера карты будет выводить имя клиента?

И что делать, если карты заведены в УКМ4?
06.10.2011 11:36
Eugin_S
 
Так не получится, я загружаю из совсем другой программы через CSV.
Я просто не знаю название класса.
06.10.2011 13:39
Eugin_S
 
Если меняю
Код:
c = discount.card_number:get();
на
Код:
c = properties_iterator:at(ukm.core.field_discount_client_name);
то получаю ошибку
Код:
18:22:27: 0x00000d10: WARNING: debug#D:\DEVEL\build-br-48_sp2-2011_08_03_14_23_52\libukm\ccore.cpp(2571) CCore::ReceiptAppendPayment: При исполнении скрипта произошла ошибка: [string "line"]:324: attempt to index global 'properties_iterator' (a nil value)
а если же переменную с меняю в строчке печати на properties_iterator:at(ukm.core.field_discount_client_name)
Код:
text = text .. ukm.adjustment(discount.name .. "    " .. properties_iterator:at(ukm.core.field_discount_client_name) .. "    " .. p, tostring(__hard_subtotal.receipt.items:getdiscount(discount):get()), width - 1, " ") .. "\n";
то отрабатывает нормально, выдает то что мне нужно, но тогда не будет обрабатываться условие.

Подскажите, в чем я ошибаюсь.
07.10.2011 10:39
vdm
 
Переместить строку
local properties_iterator = ukm.map.int.string.iterator(discount.properties);

вверх, поставить перед
if discount.card_number:is_initialized() then
12.10.2011 13:47
Eugin_S
 
Цитата:
vdm Переместить строку
local properties_iterator = ukm.map.int.string.iterator(discount.properties);

вверх, поставить перед
if discount.card_number:is_initialized() then
Да, спасибо, это помогло. Получилось вот так:
Код:
local properties_iterator = ukm.map.int.string.iterator(discount.properties);
			if discount.card_number:is_initialized() then
--                 c = discount.card_number:get();
		   c = properties_iterator:at(ukm.core.field_discount_client_name);
             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
Часовой пояс GMT +3, время: 18:53.

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