Changed invoiceOut pdf to hasPdf
gitea/salix/dev This commit has test failures Details

This commit is contained in:
Joan Sanchez 2019-07-24 12:42:33 +02:00
parent 8089c32ec2
commit 6d5412227a
4 changed files with 86 additions and 5 deletions

View File

@ -0,0 +1,24 @@
CREATE
OR REPLACE ALGORITHM = UNDEFINED
DEFINER = `root`@`%`
SQL SECURITY DEFINER
VIEW `vn`.`invoiceOut` AS
SELECT
`f`.`factura_id` AS `id`,
`f`.`Id_Factura` AS `ref`,
`f`.`Serie` AS `serial`,
`f`.`Fecha` AS `issued`,
`f`.`Importe` AS `amount`,
`f`.`Id_Cliente` AS `clientFk`,
`f`.`odbc_date` AS `created`,
`f`.`empresa_id` AS `companyFk`,
`f`.`Vencimiento` AS `dued`,
`f`.`booked` AS `booked`,
`f`.`Id_Banco` AS `bankFk`,
`f`.`cplusInvoiceType477Fk` AS `cplusInvoiceType477Fk`,
`f`.`cplusTaxBreakFk` AS `cplusTaxBreakFk`,
`f`.`cplusSubjectOpFk` AS `cplusSubjectOpFk`,
`f`.`cplusTrascendency477Fk` AS `cplusTrascendency477Fk`,
`f`.`pdf` AS `hasPdf`
FROM
`vn2008`.`Facturas` `f`;

View File

@ -0,0 +1,60 @@
DROP procedure IF EXISTS `vn`.`invoiceOutAgain`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`invoiceOutAgain`(IN vInvoiceRef VARCHAR(15), vTaxArea VARCHAR(25))
BEGIN
/* Para tickets ya facturados, vuelve a repetir el proceso de facturación.
*
* @param vInvoiceFk Numero de factura
* @param vTaxArea Numero de factura
*/
DECLARE vInvoiceFk INT;
DECLARE vCountry INT;
DECLARE vTaxArea VARCHAR(15);
DECLARE vSpainCountryCode INT DEFAULT 1;
SELECT id INTO vInvoiceFk
FROM invoiceOut
WHERE ref = vInvoiceRef;
UPDATE invoiceOut
SET hasPdf = 0
WHERE id = vInvoiceFk;
SELECT s.countryFk INTO vCountry
FROM supplier s
JOIN invoiceOut io ON io.companyFk = s.id
WHERE io.id = vInvoiceFk;
DROP TEMPORARY TABLE IF EXISTS ticketToInvoice;
CREATE TEMPORARY TABLE ticketToInvoice
SELECT id
FROM ticket
WHERE refFk = vInvoiceRef;
CALL invoiceExpenceMake(vInvoiceFk);
CALL invoiceTaxMake(vInvoiceFk,vTaxArea);
UPDATE invoiceOut io
JOIN (
SELECT SUM(amount) AS total
FROM invoiceOutExpence
WHERE invoiceOutFk = vInvoiceFk
) base
JOIN (
SELECT SUM(vat) AS total
FROM invoiceOutTax
WHERE invoiceOutFk = vInvoiceFk
) vat
SET io.amount = base.total + vat.total
WHERE io.id = vInvoiceFk;
CALL vn.invoiceOutBooking(vInvoiceFk);
END$$
DELIMITER ;

View File

@ -381,7 +381,7 @@ INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`,
(791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30'),
(1381, 'ORN', NULL, 30, NULL, 7, NULL);
INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `pdf`)
INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`)
VALUES
(1, 'T', 1014.24, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 101, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(CURDATE(), INTERVAL -1 MONTH), DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1),
(2, 'T', 121.36, CURDATE(), 102, CURDATE(), 442, CURDATE(), CURDATE(), 1, 1),

View File

@ -35,10 +35,7 @@
"type": "date"
},
"hasPdf": {
"type": "Boolean",
"mysql": {
"columnName": "pdf"
}
"type": "Boolean"
}
},
"relations": {