38 lines
874 B
SQL
38 lines
874 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`pgc_add`(vCompanyFk INT)
|
|
BEGIN
|
|
/**
|
|
* Añade cuentas del plan general contable para exportarlos a Sage
|
|
* @vCompanyFk Empresa de la que se quiere trasladar datos
|
|
*/
|
|
TRUNCATE TABLE planCuentasPGC;
|
|
|
|
INSERT INTO planCuentasPGC
|
|
(CodigoEmpresa,
|
|
CodigoCuenta,
|
|
Cuenta,
|
|
ClienteOProveedor)
|
|
SELECT *
|
|
FROM (SELECT company_getCode(vCompanyFk) companyFk,
|
|
e.id accountFk,
|
|
UCASE(e.name),
|
|
''
|
|
FROM vn.expense e
|
|
UNION
|
|
SELECT company_getCode(vCompanyFk),
|
|
b.account,
|
|
UCASE(b.bank),
|
|
''
|
|
FROM vn.bank b
|
|
WHERE b.isActive
|
|
AND b.`account`
|
|
UNION
|
|
SELECT CodigoEmpresa,
|
|
CodigoCuenta,
|
|
Nombre,
|
|
ClienteOProveedor
|
|
FROM clientesProveedores)sub
|
|
GROUP BY companyFk, accountFk;
|
|
END$$
|
|
DELIMITER ;
|