2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceFromAddress`(vMaxTicketDate DATETIME,vAddress INT,vCompany INT)
|
|
|
|
BEGIN
|
|
|
|
|
|
|
|
DECLARE vMinDateTicket DATE DEFAULT TIMESTAMPADD(MONTH, -3, util.VN_CURDATE());
|
|
|
|
|
|
|
|
SET vMaxTicketDate = util.dayEnd(vMaxTicketDate);
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`;
|
|
|
|
|
|
|
|
CREATE TEMPORARY TABLE `tmp.``ticketToInvoice`
|
|
|
|
(PRIMARY KEY (`id`))
|
2024-02-05 12:52:28 +00:00
|
|
|
ENGINE = MEMORY
|
2024-02-06 13:55:20 +00:00
|
|
|
SELECT id
|
2024-02-05 12:52:28 +00:00
|
|
|
FROM ticket
|
|
|
|
WHERE (shipped BETWEEN vMinDateTicket AND vMaxTicketDate)
|
|
|
|
AND addressFk = vAddress
|
|
|
|
AND refFk IS NULL
|
|
|
|
AND companyFk = vCompany;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|