feat: refs #7173 Bloquear facturas recibidas contabilizadas #2258
|
@ -2542,15 +2542,15 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV
|
|||
REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`)
|
||||
VALUES
|
||||
(1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1),
|
||||
(2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 1, 442, 1),
|
||||
(2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1),
|
||||
(3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1),
|
||||
(4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1),
|
||||
(5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 1, 442, 1),
|
||||
(5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1),
|
||||
(6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1),
|
||||
(7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1),
|
||||
(8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1),
|
||||
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1),
|
||||
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1);
|
||||
(7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1),
|
||||
(8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1),
|
||||
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1),
|
||||
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1);
|
||||
|
||||
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`)
|
||||
VALUES
|
||||
|
@ -2605,6 +2605,10 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo
|
|||
(2, 13.20, 5080000, 15.00, 580, 5),
|
||||
(2, 16.10, 6021010, 25.00, 80, 5);
|
||||
|
||||
UPDATE `vn`.`invoiceIn`
|
||||
SET isBooked = TRUE
|
||||
WHERE id IN (2, 5, 7, 8, 9, 10);
|
||||
|
||||
INSERT INTO `vn`.`ticketRecalc`(`ticketFk`)
|
||||
SELECT t.id
|
||||
FROM vn.ticket t
|
||||
|
|
|
@ -10,6 +10,8 @@ BEGIN
|
|||
DECLARE vLines INT;
|
||||
DECLARE vHasDistinctTransactions INT;
|
||||
|
||||
CALL invoiceIn_checkBooked(vInvoiceInFk);
|
||||
|
||||
SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig;
|
||||
|
||||
SELECT COUNT(*) INTO vLines
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkIsBooked`(
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`(
|
||||
vSelf INT
|
||||
)
|
||||
BEGIN
|
|
@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_b
|
|||
BEFORE DELETE ON `invoiceInCorrection`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkIsBooked(OLD.correctingFk);
|
||||
CALL invoiceIn_checkBooked(OLD.correctingFk);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor
|
|||
BEFORE DELETE ON `invoiceInDueDay`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkIsBooked(OLD.id);
|
||||
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -5,6 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor
|
|||
BEGIN
|
||||
DECLARE vIsNotified BOOLEAN;
|
||||
|
||||
CALL invoiceIn_checkBooked(NEW.invoiceInFk);
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
SELECT isNotified INTO vIsNotified
|
||||
|
|
|
@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_be
|
|||
BEFORE DELETE ON `invoiceInIntrastat`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkIsBooked(OLD.invoiceInFk);
|
||||
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeInsert`
|
||||
BEFORE INSERT ON `invoiceInIntrastat`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(NEW.invoiceInFk);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeDe
|
|||
BEFORE DELETE ON `invoiceInTax`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkIsBooked(OLD.invoiceInFk);
|
||||
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp
|
|||
BEFORE UPDATE ON `invoiceInTax`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkIsBooked(OLD.invoiceInFk);
|
||||
CALL invoiceIn_checkBooked(OLD.invoiceInFk);
|
||||
|
||||
IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN
|
||||
CALL invoiceInTax_afterUpsert(NEW.invoiceInFk);
|
||||
|
|
|
@ -3,8 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterDelete
|
|||
AFTER DELETE ON `invoiceIn`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkIsBooked(OLD.id);
|
||||
|
||||
INSERT INTO invoiceInLog
|
||||
SET `action` = 'delete',
|
||||
`changedModel` = 'InvoiceIn',
|
||||
|
|
|
@ -3,8 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate
|
|||
AFTER UPDATE ON `invoiceIn`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkIsBooked(OLD.id);
|
||||
|
||||
IF NEW.issued != OLD.issued
|
||||
OR NEW.currencyFk != OLD.currencyFk THEN
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeDelete`
|
||||
BEFORE DELETE ON `invoiceIn`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL invoiceIn_checkBooked(OLD.id);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -5,7 +5,9 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat
|
|||
BEGIN
|
||||
DECLARE vWithholdingSageFk INT;
|
||||
|
||||
IF NEW.isBooked = OLD.isBooked THEN
|
||||
CALL invoiceIn_checkBooked(OLD.id);
|
||||
END IF;
|
||||
|
||||
IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN
|
||||
CALL util.throw('The invoiceIn reference contains invalid characters');
|
||||
|
|
|
@ -13,11 +13,10 @@ describe('invoiceInDueDay new()', () => {
|
|||
|
||||
it('should correctly create a new due day', async() => {
|
||||
const userId = 9;
|
||||
const invoiceInFk = 6;
|
||||
const invoiceInFk = 3;
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
|
||||
accessToken: {userId: userId},
|
||||
}
|
||||
};
|
||||
|
|
|
@ -158,7 +158,7 @@ describe('InvoiceIn filter()', () => {
|
|||
|
||||
const result = await models.InvoiceIn.filter(ctx, {}, options);
|
||||
|
||||
expect(result.length).toEqual(6);
|
||||
expect(result.length).toEqual(4);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in New Issue