salix/db/routines/vn/functions/invoiceOut_getPath.sql

22 lines
480 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` FUNCTION `vn`.`invoiceOut_getPath`(vSelf INT)
RETURNS varchar(255) CHARSET utf8mb3 COLLATE utf8mb3_general_ci
DETERMINISTIC
BEGIN
DECLARE vIssued DATE;
DECLARE vSerial VARCHAR(15);
SELECT issued, ref
INTO vIssued, vSerial
FROM invoiceOut WHERE id = vSelf;
RETURN CONCAT_WS('/'
,'invoice'
,YEAR(vIssued)
,MONTH(vIssued)
,DAY(vIssued)
,CONCAT(YEAR(vIssued), vSerial, '.pdf')
);
END$$
DELIMITER ;