2024-01-15 11:31:03 +00:00
|
|
|
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),
|
|
|
|
''
|
2024-03-15 09:55:39 +00:00
|
|
|
FROM vn.expense e
|
2024-01-15 11:31:03 +00:00
|
|
|
UNION
|
|
|
|
SELECT company_getCode(vCompanyFk),
|
2024-03-14 07:36:19 +00:00
|
|
|
a.account,
|
|
|
|
UCASE(a.bank),
|
2024-01-15 11:31:03 +00:00
|
|
|
''
|
2024-03-15 09:55:39 +00:00
|
|
|
FROM vn.accounting a
|
2024-03-14 07:36:19 +00:00
|
|
|
WHERE a.isActive
|
|
|
|
AND a.`account`
|
2024-01-15 11:31:03 +00:00
|
|
|
UNION
|
|
|
|
SELECT CodigoEmpresa,
|
|
|
|
CodigoCuenta,
|
|
|
|
Nombre,
|
|
|
|
ClienteOProveedor
|
|
|
|
FROM clientesProveedores)sub
|
|
|
|
GROUP BY companyFk, accountFk;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|