2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_addItem`(
|
2024-01-15 11:31:03 +00:00
|
|
|
vBarccodeFk INT,
|
|
|
|
vQuantity INT,
|
|
|
|
vTicketFk INT
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Add a sales line to the ticket with the indicated amount.
|
|
|
|
*
|
|
|
|
* @param vBarcodeFk barcode on the item label
|
|
|
|
* @param vQuantity quantity to be added to the ticket
|
|
|
|
* @param vTicketFk ticket to which the sales line is added
|
|
|
|
*/
|
|
|
|
DECLARE vConcept VARCHAR(50);
|
|
|
|
DECLARE vItemFk INT;
|
|
|
|
DECLARE vSaleFk INT;
|
|
|
|
DECLARE vDescription VARCHAR(50);
|
|
|
|
DECLARE vItemName VARCHAR(50);
|
|
|
|
|
|
|
|
SELECT barcodeToItem(vBarccodeFk) INTO vItemFk;
|
|
|
|
|
|
|
|
SELECT CONCAT(getUser(),
|
|
|
|
' ',
|
|
|
|
DATE_FORMAT(util.VN_NOW(), '%H:%i' ),
|
|
|
|
' ',
|
|
|
|
i.name
|
|
|
|
) INTO vConcept
|
|
|
|
FROM item i
|
|
|
|
WHERE i.id = vItemFk;
|
|
|
|
|
|
|
|
SELECT name INTO vItemName FROM item WHERE id = vBarccodeFk;
|
|
|
|
|
|
|
|
SELECT CONCAT('Añadido articulo ',
|
|
|
|
vItemName,
|
|
|
|
' cantidad:',
|
|
|
|
vQuantity
|
|
|
|
) INTO vDescription;
|
|
|
|
|
|
|
|
INSERT INTO ticketLog
|
|
|
|
SET originFk = vTicketFk,
|
|
|
|
userFk = getUser(),
|
|
|
|
`action` = 'update',
|
|
|
|
`description` = vDescription;
|
|
|
|
|
|
|
|
INSERT INTO sale
|
|
|
|
SET itemFk = vItemFk,
|
|
|
|
ticketFk = vTicketFk,
|
|
|
|
concept = vConcept,
|
|
|
|
quantity = vQuantity,
|
|
|
|
isAdded = TRUE;
|
|
|
|
|
|
|
|
SELECT LAST_INSERT_ID() INTO vSaleFk;
|
|
|
|
|
2024-05-02 08:15:01 +00:00
|
|
|
UPDATE sale
|
|
|
|
SET originalQuantity = 0
|
|
|
|
WHERE id = vSaleFk;
|
|
|
|
|
2024-01-15 11:31:03 +00:00
|
|
|
CALL sale_calculateComponent(vSaleFk, NULL);
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|