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 expense e
|
|
UNION
|
|
SELECT company_getCode(vCompanyFk),
|
|
a.account,
|
|
UCASE(a.bank),
|
|
''
|
|
FROM accounting a
|
|
WHERE a.isActive
|
|
AND a.`account`
|
|
UNION
|
|
SELECT CodigoEmpresa,
|
|
CodigoCuenta,
|
|
Nombre,
|
|
ClienteOProveedor
|
|
FROM clientesProveedores)sub
|
|
GROUP BY companyFk, accountFk;
|
|
END$$
|
|
DELIMITER ;
|