2024-04-16 15:01:14 +00:00
|
|
|
DELIMITER $$
|
2024-05-02 16:13:12 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isTooLittle`(
|
|
|
|
vSelf INT
|
|
|
|
)
|
2024-04-16 15:01:14 +00:00
|
|
|
RETURNS tinyint(1)
|
|
|
|
READS SQL DATA
|
|
|
|
BEGIN
|
|
|
|
/**
|
2024-05-02 16:13:12 +00:00
|
|
|
* Check if the ticket is small based on the volume and amount parameters.
|
2024-04-16 15:01:14 +00:00
|
|
|
*
|
2024-05-13 11:31:58 +00:00
|
|
|
* @param vSelf Id ticket
|
2024-04-16 15:01:14 +00:00
|
|
|
* @return BOOL
|
|
|
|
*/
|
|
|
|
DECLARE vIsTooLittle TINYINT(1);
|
|
|
|
|
|
|
|
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
|
2024-06-05 08:03:37 +00:00
|
|
|
AND IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle
|
2024-05-03 08:19:05 +00:00
|
|
|
FROM ticket t
|
2024-04-16 15:01:14 +00:00
|
|
|
LEFT JOIN saleVolume sv ON sv.ticketFk = t.id
|
|
|
|
JOIN volumeConfig vc
|
|
|
|
WHERE t.id = vSelf;
|
|
|
|
|
|
|
|
RETURN vIsTooLittle;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|