Код:
--печать скидок чека
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) ~= 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,".") .. " " .. tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "% " .. " " .. 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,".") .. " " .. tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "% ", 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,".") .. " " .. tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "% ", 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,".") .. " " .. tostring(__hard_subtotal.receipt.items:getrealpercent(discount)) .. "% " .. " " .. tostring(__hard_subtotal.receipt.items:getdiscount(discount))) < 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)), 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)),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