2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`ticketSplitCounter`(vTicketFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
RETURNS varchar(15) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
|
|
|
|
NOT DETERMINISTIC
|
|
|
|
READS SQL DATA
|
|
|
|
BEGIN
|
|
|
|
DECLARE vSplitCounter VARCHAR(15);
|
|
|
|
|
|
|
|
SELECT CONCAT(printedStickers,'/',Total, IF(printedStickers = Total ,' LS','')) INTO vSplitCounter
|
|
|
|
FROM
|
|
|
|
(
|
2024-04-24 07:53:31 +00:00
|
|
|
SELECT count(sl.saleFk) as printedStickers, COUNT(*) as Total
|
|
|
|
FROM sale s
|
|
|
|
LEFT JOIN saleLabel sl ON sl.saleFk = s.id
|
2024-01-15 11:31:03 +00:00
|
|
|
WHERE ticketFk = vTicketFk
|
|
|
|
) sub;
|
|
|
|
|
|
|
|
RETURN IFNULL(vSplitCounter,'--');
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|