Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MySQL dump 10.13 Distrib 5.1.73, for redhat-linux-gnu (x86_64)
- --
- -- Host: localhost Database: interno
- -- ------------------------------------------------------
- -- Server version 5.1.73-log
- /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
- /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
- /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
- /*!40101 SET NAMES utf8 */;
- /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
- /*!40103 SET TIME_ZONE='+00:00' */;
- /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
- /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
- /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
- /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
- --
- -- Dumping routines for database 'interno'
- --
- /*!50003 DROP FUNCTION IF EXISTS `afegeix_lletra` */;
- /*!50003 SET @saved_cs_client = @@character_set_client */ ;
- /*!50003 SET @saved_cs_results = @@character_set_results */ ;
- /*!50003 SET @saved_col_connection = @@collation_connection */ ;
- /*!50003 SET character_set_client = utf8 */ ;
- /*!50003 SET character_set_results = utf8 */ ;
- /*!50003 SET collation_connection = utf8_general_ci */ ;
- /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
- /*!50003 SET sql_mode = '' */ ;
- DELIMITER ;;
- /*!50003 CREATE*/ /*!50020 DEFINER=`abac`@`%`*/ /*!50003 PROCEDURE `centre_exercici_eliminar_indiscriminat_assentaments`(IN _centreId INT(11), _centre_exerciciId INT(11))
- BEGIN
- SET foreign_key_checks = 0;
- delete from assentament where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- delete from assentament_cab where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- delete from pred_det where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- delete from pred_cab where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- delete from minutes_det where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- delete from minutes_cab where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- delete from fra_det where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- delete from fra_cab where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from combo_mesos where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from banc where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from canvi_patrimoni where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from ccost where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from cc_vigencia where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from inc_presupostari where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from inv_baixa where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from inv_comptes where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from inv_ubicacions where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from inventari_hist where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from inventari where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE FROM amortitza_control where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE FROM tmp_amortitza_massiu_previ where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_importacio_inventari where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_inventari_compara where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from ass_inv_info where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from ass_inv_cancel_saldo where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from model_303 where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from model_303_iva where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from pressupost where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tercers where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tipus_venciment where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_imp_tresoreria_cab where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_imp_tresoreria_det where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_importacio_errors where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_importacio_nomines where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_imputa_cc_tipus_ordre where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_imputa_pantalla_cc where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_imputa_pantalla_cc_previ where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_imputa_pantalla_recalcul where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_mayor where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_prepara_traspas_comptes where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tmp_previ_pressupost where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from compte where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from centre_constants where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from tipus_iva where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from fra_serie where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from sequence_data_comptadors where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- DELETE from combo_mesos where centre_id = _centreId and centre_exercici_id = _centre_exerciciId;
- delete from centre_exercici where centre_id = _centreId and id = _centre_exerciciId;
- END */;;
- DELIMITER ;
- /*!50003 SET sql_mode = @saved_sql_mode */ ;
- /*!50003 SET character_set_client = @saved_cs_client */ ;
- /*!50003 SET character_set_results = @saved_cs_results */ ;
- /*!50003 SET collation_connection = @saved_col_connection */ ;
- /*!50003 DROP PROCEDURE IF EXISTS `centre_exercici_tancament_obertura` */;
- /*!50003 SET @saved_cs_client = @@character_set_client */ ;
- /*!50003 SET @saved_cs_results = @@character_set_results */ ;
- /*!50003 SET @saved_col_connection = @@collation_connection */ ;
- /*!50003 SET character_set_client = latin1 */ ;
- /*!50003 SET character_set_results = latin1 */ ;
- /*!50003 SET collation_connection = latin1_swedish_ci */ ;
- /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
- /*!50003 SET sql_mode = '' */ ;
- DELIMITER ;;
- /*!50003 CREATE*/ /*!50020 DEFINER=`abac`@`%`*/ /*!50003 PROCEDURE `centre_exercici_tancament_obertura`(IN `_centre_id` INT(11) , IN `_centre_exercici_id` INT(11), IN `_comptes_no_usades` INT(1) )
- BEGIN
- -- Estaba aqui con upd comptes
- DECLARE _SEQ_IMPORTACIO INT(11);
- SET _SEQ_IMPORTACIO = nextval('centre_exercici');
- insert into centre_exercici(centre_id, usuari_creacio_id,tipcont, iniejer, finejer
- ,any_exercici, digits_compte,digits_subcompte, data_treball, nrr )
- select centre_id,999999,tipcont,DATE_ADD(iniejer, INTERVAL 1 YEAR) as iniejer ,DATE_ADD(finejer, INTERVAL 1 YEAR) as finejer
- ,DATE_FORMAT( DATE_ADD(iniejer, INTERVAL 1 YEAR),'%Y'),digits_compte,digits_subcompte,DATE_FORMAT( DATE_ADD(iniejer, INTERVAL 1 YEAR),'01-01-%Y'), _SEQ_IMPORTACIO
- from centre_exercici
- where id = _centre_exercici_id ;
- select 'centre_exercici';
- select id INTO @id_exercici from centre_exercici where centre_id = _centre_id and nrr = _SEQ_IMPORTACIO;
- select 'recuperar_exercici';
- insert into compte
- ( centre_id, centre_exercici_id, tipus_pla, comptabilitat_id, compte, compte_pare, compte_pare_id, titol,
- balanc, resultado, A_P, tipus_compte, tipus_auxiliar, criteri_imputacio, bloqueig_entrada_directa, bloquejada,
- D_H, saldo_cd, tipus_reg, cc_id, tercer, signo, signe, errsct, PGC, TITOL50)
- SELECT
- centre_id, @id_exercici, tipus_pla, comptabilitat_id, compte, compte_pare, compte_pare_id, titol,
- balanc, resultado, A_P, tipus_compte, tipus_auxiliar, criteri_imputacio, bloqueig_entrada_directa, bloquejada,
- D_H, saldo_cd, tipus_reg, cc_id, tercer, signo, signe, errsct, PGC, TITOL50
- FROM
- compte
- where centre_id = _centre_id and centre_exercici_id = _centre_exercici_id AND tipus_compte = 'M' ;
- delete from tmp_prepara_traspas_comptes where centre_id = _centre_id and centre_exercici_id =_centre_exercici_id ;
- insert into tmp_prepara_traspas_comptes(centre_id,centre_exercici_id,compte, compte_id, import_deure, import_haver)
- SELECT centre_id,centre_exercici_id, compte,compte_id, sum(import_deure), sum(import_haver) FROM assentament
- where centre_id = _centre_id and centre_exercici_id =_centre_exercici_id
- group by compte, compte_id;
- insert into tmp_prepara_traspas_comptes
- ( centre_id, centre_exercici_id, compte, compte_id)
- SELECT
- centre_id, @id_exercici, compte, id
- FROM
- compte
- WHERE compte not in ( select compte from tmp_prepara_traspas_comptes )
- and centre_id = _centre_id and centre_exercici_id = _centre_exercici_id AND tipus_compte = 'A'
- and saldo_final <> 0 ;
- IF _comptes_no_usades = 0 THEN
- insert into compte
- ( centre_id, centre_exercici_id, tipus_pla, comptabilitat_id, compte, compte_pare, compte_pare_id, titol,
- balanc, resultado, A_P, tipus_compte, tipus_auxiliar, criteri_imputacio, bloqueig_entrada_directa, bloquejada,
- D_H, saldo_cd, tipus_reg, cc_id, tercer, signo, signe, errsct, PGC, TITOL50)
- SELECT
- centre_id, @id_exercici, tipus_pla, comptabilitat_id, compte, compte_pare, compte_pare_id, titol,
- balanc, resultado, A_P, tipus_compte, tipus_auxiliar, criteri_imputacio, bloqueig_entrada_directa, bloquejada,
- D_H, saldo_cd, tipus_reg, cc_id, tercer, signo, signe, errsct, PGC, TITOL50
- FROM
- compte
- where centre_id = _centre_id and centre_exercici_id = _centre_exercici_id
- and left(compte,1) >= 1 and left(compte,1) <=7
- AND tipus_compte = 'A';
- else
- insert into compte
- ( centre_id, centre_exercici_id, tipus_pla, comptabilitat_id, compte, compte_pare, compte_pare_id, titol,
- balanc, resultado, A_P, tipus_compte, tipus_auxiliar, criteri_imputacio, bloqueig_entrada_directa, bloquejada,
- D_H, saldo_cd, tipus_reg, cc_id, tercer, signo, signe, errsct, PGC, TITOL50)
- SELECT
- c.centre_id, @id_exercici, c.tipus_pla, c.comptabilitat_id, c.compte, c.compte_pare, c.compte_pare_id, c.titol,
- c.balanc, c.resultado, c.A_P, c.tipus_compte, c.tipus_auxiliar, c.criteri_imputacio, c.bloqueig_entrada_directa,
- c.bloquejada,c.D_H,c.saldo_cd, c.tipus_reg, c.cc_id, c.tercer, c.signo, c.signe, c.errsct, c.PGC, c.TITOL50
- FROM
- compte c inner join tmp_prepara_traspas_comptes t
- where
- c.centre_id = t.centre_id and c.centre_exercici_id = t.centre_exercici_id and c.id = t.compte_id
- and c.centre_id = _centre_id and c.centre_exercici_id = _centre_exercici_id
- AND tipus_compte = 'A';
- end if;
- END */;;
- DELIMITER ;
- /*!50003 SET sql_mode = @saved_sql_mode */ ;
- /*!50003 SET character_set_client = @saved_cs_client */ ;
- /*!50003 SET character_set_results = @saved_cs_results */ ;
- /*!50003 SET collation_connection = @saved_col_connection */ ;
- /*!50003 DROP PROCEDURE IF EXISTS `centre_exercici_tancament_obertura_comptes` */;
- /*!50003 SET @saved_cs_client = @@character_set_client */ ;
- /*!50003 SET @saved_cs_results = @@character_set_results */ ;
- /*!50003 SET @saved_col_connection = @@collation_connection */ ;
- /*!50003 SET character_set_client = utf8 */ ;
- /*!50003 SET character_set_results = utf8 */ ;
- /*!50003 SET collation_connection = utf8_general_ci */ ;
- /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
- /*!50003 SET sql_mode = '' */ ;
- DELIMITER ;;
- /*!50003 CREATE*/ /*!50020 DEFINER=`abac`@`%`*/ /*!50003 PROCEDURE `centre_exercici_tancament_obertura_crea_exercici`(IN `_PROCES` VARCHAR(20), IN `_NUM_TANCAMENT` INT(11), IN `_centre_id` INT(11), IN `_centre_exercici_id` INT(11), IN `_comptes_no_usades` INT(1))
- BEGIN
- -- Estaba aqui
- INSERT INTO centre_exercici(centre_id, usuari_creacio_id, tipcont, iniejer, finejer,
- any_exercici, digits_compte, digits_subcompte, exercici_ant , data_treball, nrr, sii_activo)
- SELECT centre_id, 999999, tipcont, DATE_ADD(iniejer, INTERVAL 1 YEAR) as iniejer,
- DATE_ADD(finejer, INTERVAL 1 YEAR) as finejer, DATE_FORMAT( DATE_ADD(iniejer, INTERVAL 1 YEAR),'%Y'),
- digits_compte, digits_subcompte, _centre_exercici_id,
- DATE_FORMAT( DATE_ADD(iniejer, INTERVAL 1 YEAR),'01-01-%Y'), _SEQ_IMPORTACIO, sii_activo
- FROM centre_exercici
- WHERE id = _centre_exercici_id ;
- SELECT 'centre_exercici';
- SELECT id INTO @id_exercici from centre_exercici where centre_id = _centre_id and nrr = _SEQ_IMPORTACIO;
- SELECT 'recuperar_exercici';
- INSERT INTO compte
- ( centre_id, centre_exercici_id, tipus_pla, comptabilitat_id, compte, compte_pare, compte_pare_id, titol,
- balanc, resultado, A_P, tipus_compte, tipus_auxiliar, criteri_imputacio, bloqueig_entrada_directa, bloquejada,
- D_H, saldo_cd, tipus_reg, cc_id, tercer, signo, signe, errsct, PGC, TITOL50)
- SELECT
- centre_id, @id_exercici, tipus_pla, comptabilitat_id, compte, compte_pare, compte_pare_id, titol,
- balanc, resultado, A_P, tipus_compte, tipus_auxiliar, criteri_imputacio, bloqueig_entrada_directa, bloquejada,
- D_H, saldo_cd, tipus_reg, cc_id, tercer, signo, signe, errsct, PGC, TITOL50
- FROM
- compte
- where centre_id = _centre_id and centre_exercici_id = _centre_exercici_id AND tipus_compte = 'M' ;
- IF _NUM_TANCAMENT <> 0 THEN
- insert into tancaments(proces,num_tancament,centre_id,centre_exercici_id,paso,processada,resultat,centre_id_NOU,centre_exercici_id_NOU,comptes_no_usades)
- values(_PROCES,_NUM_TANCAMENT,_centre_id,_centre_exercici_id,'exercici','1','ok',_centre_id,@id_exercici,_comptes_no_usades);
- END IF;
- SELECT "ok";
- END */;;
- DELIMITER ;
- /*!50003 SET sql_mode = @saved_sql_mode */ ;
- /*!50003 SET character_set_client = @saved_cs_client */ ;
- /*!50003 SET character_set_results = @saved_cs_results */ ;
- /*!50003 SET collation_connection = @saved_col_connection */ ;
- /*!50003 DROP PROCEDURE IF EXISTS `centre_exercici_traspas_saldos` */;
- /*!50003 SET @saved_cs_client = @@character_set_client */ ;
- /*!50003 SET @saved_cs_results = @@character_set_results */ ;
- /*!50003 SET @saved_col_connection = @@collation_connection */ ;
- /*!50003 SET character_set_client = latin1 */ ;
- /*!50003 SET character_set_results = latin1 */ ;
- /*!50003 SET collation_connection = latin1_swedish_ci */ ;
- /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
- /*!50003 SET sql_mode = '' */ ;
Add Comment
Please, Sign In to add comment