18.03.2015 11:00
murlandi
 
Была задача добавить группу бонусных карт, в итоге добавил новый узел клиентов, назначил скидку (На чек по сумме счета зарегистрированного клиента (расчет скидок)), изменил в lua-скрипте значения.
В итоге, в чеке выводится информация:
X.XX - Накопленное количество бонусов - (до покупки)
Y.YY - Накопленное количество бонусов - (после покупки)

Надо и было ранее (до изменений):
Z.ZZ - Общая сумма покупок в сети
Y.YY - Накопленное количество бонусов - (после покупки)

В чем допущена ошибка?
Скрипт:
Цитата:
-- Модуль печати чека
--переменная для сжатой печати kklnmiojoim
compresed_print = false;

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

if parsing_modificator.prefix == "-" then
modif = modif .. "Возможная скидка ";
elseif parsing_modificator.prefix == "+" then
modif = modif .. "Возможная наценка ";
elseif parsing_modificator.prefix == "" then
modif = modif .. "Возможная стоимость ";
elseif parsing_modificator.prefix == "p" then
modif = modif .. "Возможный вид цены ";
end

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_exists() 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.position == 0 then
text = text .. ukm.rightpad("Е/И*К-ВО СТОИМОСТЬ(РУБ)", width-1, " ") .. "\n";
end
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

text = text .. ukm.left(__item.item .. " " .. __item.name, width - 1) .. "\n";
for i = 0, __item.properties:size() - 1 do
local property = __item.properties:at(i);
if (ukm.binary(property.flags) *
ukm.binary(ukm.item_property.flgprint)):get() ~= 0 then
local property_name = property.code;
if property.name:is_initialized() then
property_name = property.name:get();
end
text = text .. ukm.adjustment(" " .. property_name, property.value .. " ", width, " ") .. "\n";
end
end

if ukm.str_len(" " .. __item.measurement .. "*" .. tostring(__item.totalquantity) .. "*" .. tostring(__item.price) .. " " .. tostring(__item.total) .. itemsign) < (width + 1) then
text = text .. ukm.adjustment(" " .. __item.measurement .. "*" .. tostring(__item.totalquantity) .. "*" .. tostring(__item.price), tostring(__item.total) .. itemsign, width, " ") .. "\n";
else
text = text .. ukm.rightpad(" " .. __item.measurement .. "*" .. tostring(__item.totalquantity) .. "*" .. tostring(__item.price) .. " ", width-1, ".") .. "\n";
text = text .. ukm.leftpad(tostring(__item.total) .. itemsign, width, ".") .. "\n";
end

-- Печать модификаторов
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

-- Печать продавцов
if ukm.get_store().print_in_receipt==true then
if __item.seller:is_initialized() then
local seller=__item.seller:get();
text = text .. ukm.left(seller.code.." "..seller.name, width) .. "\n";
end
end


-- Закоментированная возможность печати налогов и скидок сразу после товарной позиции в теле чека
-- if compresed_print == false then
-- local taxes = ukm.taxes(__item.receipt);
-- taxes:create(__item);
-- for i=0, taxes.itemtaxes:size()-1 do
-- local tax = taxes.itemtaxes:at(i);
-- text = text .. ukm.adjustment(" " .. tax.name .. ", " .. tax.percent, tostring(tax.amount) .. " ", width, " ") .. "\n";
-- end
-- else
-- for key, tax in pairs(__item.tax_item) do
-- text = text .. ukm.adjustment(" " .. tax.name .. ", " .. tax.percent, tostring(tax.amount) .. " ", width, " ") .. "\n";
-- end
-- end
--
-- if compresed_print == false then
-- for i=0,__item.discounts:size()-1 do
-- local discount = __item.discounts:at(i);
-- if discount.increment:sign() ~= 0 then
-- if discount.increment:sign() == 1 then
-- text = text .. ukm.adjustment(" " .. discount.receiptdiscount.name, tostring(discount.increment) .. " ", width, " ") .. "\n";
-- else
-- text = text .. ukm.adjustment(" " .. discount.receiptdiscount.name, tostring(discount.increment*ukm.currency(-1)) .. " ", width, " ") .. "\n";
-- end
-- end
-- end
-- else
-- for key, discount in pairs(__item.discounts) do
-- if discount.increment:sign() ~= 0 then
-- if discount.increment:sign() == 1 then
-- text = text .. ukm.adjustment(" " .. discount.name, tostring(discount.increment) .. " ", width, " ") .. "\n";
-- else
-- text = text .. ukm.adjustment(" " .. discount.name, tostring(discount.increment*ukm.currency(-1)) .. " ", width, " ") .. "\n";
-- end
-- end
-- end
-- end

-- Изменения
local bonus_discount_type = 9; -- Выводим накопления только по этой скидке
local bonus_discount_type2 = 97; -- Выводим накопления только по этой скидке

local receipt_type = __item.receipt.header:receipt_type();
if receipt_type == ukm.header.sale or receipt_type == ukm.header.pop then

if __item.receipt.header:client_exists() then
if compresed_print == false then
for i=0,__item.discounts:size()-1 do
local discount = __item.discounts:at(i);

-- if discount.receiptdiscount.discount_type_id == bonus_discount_type then -- оригинал

if discount.receiptdiscount.discount_type_id == bonus_discount_type or discount.receiptdiscount.discount_type_id == bonus_discount_type2 then -- если убрать этот if, то будут выведены все скидки приводящие к изменению баланса счета
if discount.account_increment:sign() ~= 0 then
if discount.account_increment:sign() == 1 then
text = text .. ukm.adjustment(" " .. discount.receiptdiscount.name, tostring(discount.account_increment) .. " ", width, " ") .. "\n";
else
text = text .. ukm.adjustment(" " .. discount.receiptdiscount.name, tostring(discount.account_increment*ukm.currency(-1)) .. " ", width, " ") .. "\n";
end
end
end
end
else
for key, discount in pairs(__item.discounts) do
if discount.receiptdiscount.discount_type_id == bonus_discount_type or discount.receiptdiscount.discount_type_id == bonus_discount_type2 then -- если убрать этот if, то будут выведены все скидки приводящие к изменению баланса счета
if discount.account_increment:sign() ~= 0 then
if discount.account_increment:sign() == 1 then
text = text .. ukm.adjustment(" " .. discount.name, tostring(discount.account_increment) .. " ", width, " ") .. "\n";
else
text = text .. ukm.adjustment(" " .. discount.name, tostring(discount.account_increment*ukm.currency(-1)) .. " ", width, " ") .. "\n";
end
end
end
end
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

text = text .. print_header_info(__receiptlink.receipt.link.headerlink);
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_stock_total(__stock, __amount, __print_data)
local printer = ukm.get_printer(ukm.printer_type_master());
if printer then
local text = "";
local width = printer:get_width();
text = text .. ukm.adjustment("Итого по " .. __stock.name .. ":", tostring(__amount) .. " ", width, ".") .. "\n";
__print_data:add(text, ukm.printer_type_master());
end
end

function print_discount(__discount, __print_data)
local printer = ukm.get_printer(ukm.printer_type_master());
if printer then
local text = "";
local width = printer:get_width();

if __discount.receipt.type ~= ukm.core.goods_receipt then
if __discount.card_number:is_initialized() and __discount.card_number:get() ~= "" then
text = text .. "Дисконтная карта" .. "\n";
text = text .. ukm.adjustment( __discount.name, __discount.card_number:get(), width, ".") .. "\n";
__print_data:add(text, ukm.printer_type_master());
end
end
end
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("К ЗАЧИСЛЕНИЮ," .. ukm.str_upper(v["NAME"]), tostring(v["REALAMOUNT"]) .. " ", width, " ") .. "\n";
text = text .. ukm.adjustmentdouble("КОМИССИЯ," .. ukm.str_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.rightpad("ТОВАРОВ В ЧЕКЕ: " .. tostring(__hard_subtotal.receipt.subtotal.itemscount), width, " ") .. "\n";
if __hard_subtotal.receipt:receipt_discount_amount():sign() ~= 0 then

if ukm.str_len("ИТОГО: " .. ukm.leftpad(tostring(__hard_subtotal.receipt.subtotal.amount + __hard_subtotal.receipt:receipt_discount_amount()) , 14, ".") .. " ") < (width + 1) then
text = text .. ukm.leftpad("ИТОГО: " .. ukm.leftpad(tostring(__hard_subtotal.receipt.subtotal.amount + __hard_subtotal.receipt:receipt_discount_amount()) , 14, ".") .. " ", width, " ") .. "\n";
else
text = text .. ukm.rightpad("ИТОГО: ", width, ".") .. "\n";
text = text .. ukm.leftpad(tostring(__hard_subtotal.receipt.subtotal.amount + __hard_subtotal.receipt:receipt_discount_amount()), width, ".") .. "\n";
end
end
--печать скидок чека

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

if __hard_subtotal.receipt.items:getdiscount(discount):get():sign() == -1 then
if ukm.str_len("Наценка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "% " .. " " .. tostring(__hard_subtotal.receipt.items:getdiscount(discount):get()*ukm.currency(-1))) < width then
text = text .. ukm.adjustment("Наценка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "% ", tostring(__hard_subtotal.receipt.items:getdiscount(discount):get()*ukm.currency(-1)), width-1, ".") .. "\n";
else
text = text .. ukm.rightpad("Наценка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "% ", width-1, ".") .. "\n";
text = text .. ukm.leftpad(tostring(__hard_subtotal.receipt.items:getdiscount(discount):get()*ukm.currency(-1)),width-1,".") .. "\n";
end
else
if ukm.str_len("Скидка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "% " .. " " .. tostring(__hard_subtotal.receipt.items:getdiscount(discount):get())) < width then
text = text .. ukm.adjustment("Скидка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "% ", tostring(__hard_subtotal.receipt.items:getdiscount(discount):get()), width-1, ".") .. "\n";
else
text = text .. ukm.rightpad("Скидка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "% ", width-1, ".") .. "\n";
text = text .. ukm.leftpad(tostring(__hard_subtotal.receipt.items:getdiscount(discount):get()),width-1,".") .. "\n";
end
end

local properties_iterator = ukm.map.int.string.iterator(discount.properties);
if properties_iterator:at(ukm.core.field_discount_modificator) ~= "" then
local modif = "возможное значение ";
--выполнение парсинга значения модификатора, и преобразование сохранённых в базе значений в строковый вид для печати
local modificator = properties_iterator:at(ukm.core.field_discount_modificator);
local human_modificator = modificator_to_human(modificator);
if properties_iterator:at(ukm.core.field_discount_client_name) ~= "" then
text = text .. ukm.rightpad(ukm.left(properties_iterator:at(ukm.core.field_discount_client_name), width - ukm.str_len(human_modificator) - 2) .. ", " .. human_modificator, width, " ") .. "\n";
else
text = text .. ukm.adjustment(human_modificator, " ", width, " ") .. "\n";
end
end
end
end

text = text .. print_netto_subtotal(__hard_subtotal.receipt.items:leavenormal());

if ukm.str_len(ukm.leftpad("К ОПЛАТЕ:." .. ukm.leftpad(tostring(__hard_subtotal.receipt.subtotal.amount), 14, ".") .. " ", width, " ")) < (width + 1) then
text = text .. ukm.leftpad("К ОПЛАТЕ:." .. ukm.leftpad(tostring(__hard_subtotal.receipt.subtotal.amount), 14, ".") .. " ", width, " ") .. "\n";
else
text = text .. ukm.rightpad("К ОПЛАТЕ:.", width, ".") .. "\n";
text = text .. ukm.leftpad(tostring(__hard_subtotal.receipt.subtotal.amount) .. " " ,width, ".") .. "\n";
end

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


--печать налогов

if __hard_subtotal.receipt.taxes:empty() == false then
text = text .. "Включая налоги:" .. "\n";

rtax = {};
for i=0, __hard_subtotal.receipt.taxes.itemtaxes:size()-1 do
local tax = __hard_subtotal.receipt.taxes.itemtaxes:at(i);
local key = tostring(tax.taxid) .. "_" .. tax.percent;
if rtax[key] == nil then
rtax[key] = {};
rtax[key].name = tax.name;
rtax[key].amount = ukm.currency(0);
rtax[key].percent = tax.percent;
end
rtax[key]["amount"] = rtax[key]["amount"] + tax.amount;
end

for rk, rv in pairs(rtax) do
text = text .. ukm.adjustment(rv.name,rv.percent .. ukm.leftpad(tostring(rv.amount) .. " ", width-23, " ") , width, " ") .. "\n";
end
end

-- Изменения
local receipt_type = __hard_subtotal.receipt.header:receipt_type();
if receipt_type == ukm.header.sale or receipt_type == ukm.header.pop then

local bonus_receipt_sum = ukm.currency(0); -- тут вычисляем сумму начисления из скидки в чеке
local bonus_discount_type = 9; -- сейчас отображаются данные только по одной скидке с таким ID
local bonus_discount_type2 = 97; -- сейчас отображаются данные только по одной скидке с таким ID

-------------
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

-- Изменения
if (discount.discount_type_id == bonus_discount_type or discount.discount_type_id == bonus_discount_type2) and __hard_subtotal.receipt.items:getdiscountaccount(discount):is_initialized() then
local discount_amount = __hard_subtotal.receipt.items:getdiscountaccount(discount):get();
if discount_amount:sign() == -1 then
discount_amount = discount_amount * ukm.currency(-1);
end
bonus_receipt_sum = bonus_receipt_sum + discount_amount;
end
-------------
end

-- Изменения

local bonus_account_name = "Накопленное количество бонусов"; -- выводим накопления только по этому счету
if __hard_subtotal.receipt.header:client_exists() then
local account = ukm.map.string.struct_balance_info.iterator(ukm.get_client_open_account_info(__hard_subtotal.receipt.header.client).account_balance_info);
while account:next() do
if account:first() == bonus_account_name then
local account_name = account:first();
account_name = 'Накопленное количество бонусов'; -- Если надо выводить название счета, то убрать эту строку
text = text .. ukm.rightpad(tostring(account:second().balance + bonus_receipt_sum) .. " - " ..account_name , width, " ") .. "\n";
end
end
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 ukm.str_len(paytype .. "," .. ukm.str_upper(__payment.paymentname) .. ":." .. ukm.leftpad(tostring(__payment.amountwithchange), 14 ,".") .. npaytype) < (width + 1) then
text = text .. ukm.leftpad(paytype .. "," .. ukm.str_upper(__payment.paymentname) .. ":." .. ukm.leftpad(tostring(__payment.amountwithchange), 14 ,".") .. npaytype, width ," ") .. "\n";
else
text = text .. ukm.rightpad(paytype .. "," .. ukm.str_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
text = text .. print_header_info(__header);

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_exists()) 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_exists()) 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

function get_discount_message_text(__discount_data, __discount)
return "Поздравляем, настройки верны!";
end

function print_header_info(__header)
local printer = ukm.get_printer(ukm.printer_type_master());
local text = "";
local width = printer:get_width();
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
return text;
end
18.03.2015 11:40
Mtirt
 
А можете показать, что было в чеке ДО, а что - сейчас?
Т.е. сам чек.
18.03.2015 14:22
murlandi
 
пример сканов приложил
Миниатюры
Нажмите на изображение для увеличения
Название: чек.jpg
Просмотров: 682
Размер:	78.9 Кб
ID:	4463  
Часовой пояс GMT +3, время: 17:05.

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