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

Не работает печать чека во время расчета : УКМ-4

01.12.2024 20:10


28.05.2016 05:44
Стоит задача печатать чек во время расчета. В параметрах указываю тип печати чека = "Во время расчета". Делаю принудительную выгрузку настроек на кассу. Но результат не получается достигнуть, печатается только начало чека с указанием его номера в виде слипа без отрезки, остальные позиции печатаются после завершения чека. Может еще есть галки, которые забыл проставить?

P.S УКМ 70 sp2
28.05.2016 07:30
В чек должна печататься подтверждённая позиция.
В настройках ФР стоит печать "свободной строкой"?
28.05.2016 15:20
Да стоит, в настройках конфигурационной группы. Пробовал ставить галочку, для дисплея покупателя выводить подтвержденную позицию.
29.05.2016 17:52
receipt.lua родной или что-то до/переписывали?
в самом начале compressed_print= чему?
true или false
29.05.2016 18:40
Цитата:
Павел Сосновских receipt.lua родной или что-то до/переписывали?
в самом начале compressed_print= чему?
true или false
1. receipt.lua переписанный, если есть родной от 70 sp2 поделитесь.
2. compresed_print = true
30.05.2016 04:14
Цитата:
Tiger 2. compresed_print = true
Вот и причина.
30.05.2016 17:09
-- Модуль печати чека
--переменная для сжатой печати
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 ~= nil then
modif = modif .. tostring(parsing_modificator.value);
end

if parsing_modificator.suffix == "%" then
modif = modif .. "%";
end
else
if parsing_modificator.pricelist_id ~= nil 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 ~= nil then
-- text = text .. ukm.adjustment("Отчество:", __header.client.patronymic:get(), __width, " ") .. "\n";
-- end
-- if __header.client.enterprisename ~= nil then
-- text = text .. ukm.adjustment("Название:", __header.client.enterprisename:get(), __width, " ") .. "\n";
-- end
-- if __header.client.inn ~= nil then
-- text = text .. ukm.adjustment("ИНН:", __header.client.inn:get(), __width, " ") .. "\n";
-- end
-- if __header.client.passport ~= nil 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 ~= nil then
if __item.remain: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 itemname = ukm.insert_delimiters(__item.item .. " " .. __item.name, "\n", width-1);
text = text .. ukm.adjustment(itemname, " ", 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 ~= nil 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 ~= nil then
local seller=__item.seller;
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
-- Печать точек хранения
if __item.storage_places ~= nil then
if __item.storage_places:size() > 0 and __item.type ~= ukm.item.cancel then
for i=0, __item.storage_places:size()-1 do
local place = __item.storage_places:at(i);
text = text .. ukm.leftpad(place .. " ", 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

text = text .. print_header_info(__receiptlink.receipt.link.headerlink);
text = text .. print_client(__receiptlink.receipt.link.headerlink, width);
text = text .. print_order(__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 ~= nil 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 ~= nil 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 discount.efts ~= ukm.core.efts_payment_discount_type and
__hard_subtotal.receipt.items:getdiscount(discount) ~= nil and __hard_subtotal.receipt.items:getdiscount(discount):sign() ~= 0 then

if __hard_subtotal.receipt.items:getdiscount(discount):sign() == -1 then
if ukm.str_len("Наценка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. ukm.dbl2str(__hard_subtotal.receipt.items:getrealpercent_dbl(discount),0,"",2,"0") .. "% " .. " " .. tostring(__hard_subtotal.receipt.items:getdiscount(discount)*ukm.currency(-1))) < width then
text = text .. ukm.adjustment("Наценка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. ukm.dbl2str(__hard_subtotal.receipt.items:getrealpercent_dbl(discount),0,"",2,"0") .. "% ", tostring(__hard_subtotal.receipt.items:getdiscount(discount)*ukm.currency(-1)), width-1, ".") .. "\n";
else
text = text .. ukm.rightpad("Наценка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. ukm.dbl2str(__hard_subtotal.receipt.items:getrealpercent_dbl(discount),0,"",2,"0") .. "% ", width-1, ".") .. "\n";
text = text .. ukm.leftpad(tostring(__hard_subtotal.receipt.items:getdiscount(discount)*ukm.currency(-1)),width-1,".") .. "\n";
end
else
if ukm.str_len("Скидка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. ukm.dbl2str(__hard_subtotal.receipt.items:getrealpercent_dbl(discount),0,"",2,"0") .. "% " .. " " .. tostring(__hard_subtotal.receipt.items:getdiscount(discount))) < width then
text = text .. ukm.adjustment("Скидка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. ukm.dbl2str(__hard_subtotal.receipt.items:getrealpercent_dbl(discount),0,"",2,"0") .. "% ", tostring(__hard_subtotal.receipt.items:getdiscount(discount)), width-1, ".") .. "\n";
else
text = text .. ukm.rightpad("Скидка: " .. ukm.rightpad(ukm.left(discount.name, width-28),width-28,".") .. " " .. ukm.dbl2str(__hard_subtotal.receipt.items:getrealpercent_dbl(discount),0,"",2,"0") .. "% ", width-1, ".") .. "\n";
text = text .. ukm.leftpad(tostring(__hard_subtotal.receipt.items:getdiscount(discount)),width-1,".") .. "\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
for a=0, discount.accepted_coupons:size()-1 do
local coupon = discount.accepted_coupons:at(a);
text = text .. " " .. ukm.adjustment(coupon.coupontype, coupon.number, width-3, " ") .. " \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-3) .. "\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

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 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 coup_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(ukm.left(__header.login.name, width-16), 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 .. print_order(__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



for i=0, __footer.receipt.discounts:size()-1 do

local discount = __footer.receipt.discounts:at(i);
local properties_iterator = ukm.map.int.string.iterator(discount.properties);

local slip_index = ukm.core.field_discount_slip_script;
local discount_slip = properties_iterator:at(slip_index);
if( discount_slip ~= "") then
text = text .. ukm.source(ukm.mashine.handle,discount_slip);
end

end

-- печатаем скидки на виды оплаты
for i=0, __footer.receipt.discounts:size()-1 do
local discount = __footer.receipt.discounts:at(i);
if discount.efts == ukm.core.efts_payment_discount_type then
local items_discount = tostring(__footer.receipt.items:getdiscount(discount));
if items_discount ~= "0.00" then
local properties_iterator = ukm.map.int.string.iterator(discount.properties);
local prop_value = properties_iterator:at(ukm.core.field_discount_payment_name);

text = text .. "Скидка на вид оплаты:" .. "\n";
text = text .. ukm.adjustment(prop_value .. " " .. ukm.dbl2str(__footer.receipt.items:getrealpercent_dbl(discount),0,"",2,"0") .. "% ", items_discount,width,".");
text = text .. "\n";
end
end
end

if __footer.result == ukm.footer.normal then
local diff = __footer.receipt:get_clear_total() - __footer.receipt:receipt_amount();
if diff > ukm.currency(0) then
text = text .. ukm.adjustment( "Вы сэкономили ", tostring(diff), width - 1, " ") .. "\n";
end

for i=0, __footer.receipt.discounts:size()-1 do
local discount = __footer.receipt.discounts:at(i);
local properties_iterator = ukm.map.int.string.iterator(discount.properties);

local txt_index = ukm.core.field_discount_print_message;
local txt_msg = properties_iterator:at(txt_index);
if( txt_msg ~= "") then
text = text .. txt_msg .. "\n";
end
end


if __footer.receipt.aoomodeles:size() > 0 then
text = text .. ukm.adjustment("Ваши накопления", "Остаток", width -1, " ") .. "\n";
for i = 0, __footer.receipt.aoomodeles:size()-1 do
local model = __footer.receipt.aoomodeles:at(i);
local signamount = " ";
if(model.optype == 2) then
signamount = " -";
else
signamount = " +";
end
local strvalue = signamount .. tostring(model.amount);
local strname = ukm.left(model:get_account_type_name(),width - 12 - ukm.str_len(strvalue));
text = text .. ukm.adjustment(ukm.adjustment(strname , strvalue, width - 12, " "), " " .. tostring(model.balanceafter), width -1, " ") .. "\n";

end
end



-- Информация по внутренним счетам:
text = text .. get_accounts_info_to_receipt_footer(__footer);


if(__footer.receipt.fiscal_string ~= nil) then
text = text .. ukm.adjseparatedlines(__footer.receipt.fiscal_string, width) .. "\n";
end


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.adjustmentdouble("ЧЕК:" .. 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

local barCode = __header:get_barcode(__header.localnumber);
if ukm.str_len(barCode) > 1 then
text = text .. ukm.center(hw_command_document_barcode(barCode), width, " ") .. " \n";
end

return text;
end

function print_return_normal_act(__receipt, __print_data)
local printer = ukm.get_printer(ukm.printer_type_master());
local width = printer:get_width();
local dateTime = ukm.ptime2str(ukm.get_sys_date(), "%d.%m.%Y %H:%M");
local text = ukm.center("Акт", width - 2, " ") .. "\n" .. ukm.center("о возврате товара и средств", width - 2, " ") .. "\n";
local price_vector = ukm.explode(tostring( __receipt:receipt_amount()),".");


text = text .. ukm.center("покупателю", width - 2, " ") .. "\n";
text = text .. ukm.center("", width - 2, "_") .. "\n";
text = text .. ukm.center("", width - 2, "_") .. "\n";
text = text .. ukm.center("", width - 2, "_") .. "\n";
text = text .. ukm.center("Документ покупателя", width - 2, " ") .. "\n";
text = text .. ukm.center("", width - 2, "_") .. "\n";
text = text .. ukm.center("", width - 2, "_") .. "\n";
text = text .. ukm.center("", width - 2, "_") .. "\n";
text = text .. ukm.center("", width - 2, "_") .. "\n";
text = text .. ukm.center("", width - 2, "_") .. "\n";
text = text .. ukm.center("", width - 2, "_") .. "\n";
text = text .. ukm.center("", width - 2, "_") .. "\n";
text = text .. ukm.center("Выдана денежная сумма в размере", width - 2, " ") .. "\n";
text = text .. ukm.center(price_vector:at(0) .. "руб." .. price_vector:at(1) .. "коп.", width - 2, " ") .. "\n";
text = text .. ukm.center("За возвращенный товар", width - 2, " ") .. "\n";

for i = 0, __receipt.items:size() - 1 do
text = text .. ukm.adjustment(__receipt.items:at(i).item , __receipt.items:at(i).name, width - 2, " ") .. "\n";
text = text .. ukm.adjustment(__receipt.items:at(i).measurement .. "*" .. tostring(__receipt.items:at(i).totalquantity) .. "*" .. tostring(__receipt.items:at(i).price), tostring(__receipt.items:at(i).total), width, " ") .. "\n";
end

text = text .. ukm.center("По кассовому чеку, выданному при", width - 2, " ") .. "\n";
text = text .. ukm.center("покупке товара", width - 2, " ") .. "\n";
text = text .. __receipt.header.pos .. "." .. __receipt.header.shiftopen.number .. "." .. __receipt.header.localnumber .. " " .. dateTime .. "\n";

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

function print_return_by_mistake_act(__receipt, __print_data)
local printer = ukm.get_printer(ukm.printer_type_master());
local width = printer:get_width();

local text = ukm.center("Акт", width - 2, " ") .. "\n" .. ukm.center("об ошибочно проведенной на РРО", width - 2, " ") .. "\n" .. ukm.center("сумме продаж", width - 2, " ") .. "\n\n";
text = text .. ukm.center("На денежную сумму в размере",width-2," ") .. "\n" .. ukm.center(tostring( __receipt:receipt_amount() ), width - 2, " ") .. "\n\n";
text = text .. ukm.center("Реквизиты расчетного",width-2," ") .. "\n";
text = text .. ukm.center("чека:",width-2," ") .. "\n";
text = text .. ukm.center(__receipt.header.pos .. "." .. __receipt.header.shiftopen.number .. "." .. __receipt.header.localnumber, width - 2, " ") .. "\n";
text = text .. "\n"
text = text .. ukm.center("",width-2,"_") .. "\n";
text = text .. ukm.center("",width-2,"_") .. "\n";
text = text .. " Члены комиссии:\n"
text = text .. ukm.center("",width-2,"_") .. "\n";
text = text .. ukm.center("",width-2,"_") .. "\n";
text = text .. ukm.center("",width-2,"_") .. "\n";
text = text .. ukm.center("",width-2,"_") .. "\n";
__print_data:add(text, ukm.printer_type_master());
end

function print_user_act(__receipt, __print_data)
local printer = ukm.get_printer(ukm.printer_type_master());
local width = printer:get_width();
local text = ukm.center("Пользовательский акт о возврате", width - 2, " ") .. "\n";
__print_data:add(text, ukm.printer_type_master());
end

function print_item_to_printer_62(__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 ~= nil then
if __item.remain: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 itemname = ukm.insert_delimiters(__item.item .. " " .. __item.name, "\n", width-1);
text = text .. ukm.adjustment(itemname, " ", 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 ~= nil then
property_name = property.name:get();
end
local prop_text;
if property.name ~= nil then
prop_text = ukm.adjustment(" " .. property_name, property.value .. " ", width, " ") .. "\n";
else
prop_text = ukm.adjustmentlines(property.value, width, " ");
end
text = text .. prop_text .. "\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 ~= nil then
local seller=__item.seller;
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
-- Печать точек хранения
if __item.storage_places ~= nil then
if __item.storage_places:size() > 0 and __item.type ~= ukm.item.cancel then
for i=0, __item.storage_places:size()-1 do
local place = __item.storage_places:at(i);
text = text .. ukm.leftpad(place .. " ", width, " ") .. "\n";
end
end
end
text = text .. hw_command_normal_color;
__print_data:add(text, ukm.printer_type_master());
end
end
-- Информация по внутренним счетам:
function get_accounts_info_to_receipt_footer(__footer)
local printer = ukm.get_printer(ukm.printer_type_master());
local width = printer:get_width();
local text = "";
while (__footer.receipt.aoo_balances:get_next_printed_account_info()) do
if __footer.receipt.aoo_balances:get_printed_account_is_open() then
text = text .. __footer.receipt.aoo_balances:get_printed_account_name() .. "\n";

local is_moved = 0;
local increased = __footer.receipt.aoo_balances:get_printed_account_increased();
local decreased = __footer.receipt.aoo_balances:get_printed_account_decreased();
local balance_received = 0;
if increased > ukm.currency(0) then
is_moved = 1;
end
if decreased > ukm.currency(0) then
is_moved = 1;
end
if __footer.receipt.aoo_balances:get_printed_account_balance_received() then
balance_received = 1;
end

if is_moved == 1 then
if balance_received == 1 then
text = text .. ukm.adjustment( " Начальный баланс", tostring(__footer.receipt.aoo_balances:get_printed_account_initial_balance()), width - 1, " ") .. "\n";
else
text = text .. ukm.adjustment( " Начальный баланс", "недоступен", width - 1, " ") .. "\n";
end
if increased > ukm.currency(0) then
text = text .. ukm.adjustment( " Начислено", tostring(increased), width - 1, " ") .. "\n";
end
if decreased > ukm.currency(0) then
text = text .. ukm.adjustment( " Списано", tostring(decreased), width - 1, " ") .. "\n";
end
if balance_received == 1 then
text = text .. ukm.adjustment( " Итоговый баланс", tostring(__footer.receipt.aoo_balances:get_printed_account_result_balance()), width - 1, " ") .. "\n";
end
else
if balance_received == 1 then
text = text .. ukm.adjustment( " Баланс", tostring(__footer.receipt.aoo_balances:get_printed_account_initial_balance()), width - 1, " ") .. "\n";
else
text = text .. ukm.adjustment( " Баланс", "недоступен", width - 1, " ") .. "\n";
end
end
end
end

if __footer.receipt.aoo_balances:is_balances_online_received() == false then
text = text .. ukm.insert_delimiters("Информация по счетам недоступна", "\n", width-1) .."\n";
text = text .. ukm.insert_delimiters("Отсутствует связь с сервером", "\n", width-1) .."\n";
end

return text;
end



function print_order(__header, __width)
local text = "";
if __header.receipt.ext_order ~= nil then
text = text .. ukm.adjustment("Тип заказа:", __header.receipt.ext_order.ext_order_type, __width, " ") .. "\n";
text = text .. ukm.adjustment("Номер заказа:", __header.receipt.ext_order:get_ext_order_id_short(), __width, " ") .. "\n";
if __header.receipt.ext_order.order_date ~= nil then
text = text .. ukm.adjustment("Дата заказа:", __header.receipt.ext_order.order_date:to_string("dd.MM.yyyy hh:mm:ss"), __width, " ") .. "\n";
end
end

return text;
end



Попробуй вот этот. 70sp2. Что то допиливали по мелочи. Но кардинальных изменений, затрагивающих печать чека не вносили.
Часовой пояс GMT +3, время: 20:10.

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