Example #1
0
 protected function process()
 {
     $this->cuenta_especial = new cuenta_especial();
     if (isset($_POST['idcuentaesp'])) {
         /// crear/editar una cuentaesp
         $cesp0 = $this->cuenta_especial->get($_POST['idcuentaesp']);
         if (!$cesp0) {
             $cesp0 = new cuenta_especial();
             $cesp0->idcuentaesp = $_POST['idcuentaesp'];
         }
         $cesp0->descripcion = $_POST['descripcion'];
         if ($cesp0->save()) {
             $this->new_message('Datos guardados correctamente.');
         } else {
             $this->new_error_msg('Imposible guardar los datos.');
         }
     } else {
         if (isset($_GET['delete'])) {
             $cesp0 = $this->cuenta_especial->get($_GET['delete']);
             if ($cesp0) {
                 if ($cesp0->delete()) {
                     $this->new_message('Identificador ' . $_GET['delete'] . ' eliminado correctamente.');
                 } else {
                     $this->new_error_msg('Imposible eliminar los datos.');
                 }
             }
         }
     }
 }
 protected function process()
 {
     $this->ppage = $this->page->get('contabilidad_cuentas');
     $this->custom_search = TRUE;
     $this->cuenta_especial = new cuenta_especial();
     if (isset($_POST['descripcion'])) {
         /// si tenemos el id, buscamos el cuenta_especial y así lo modificamos
         if (isset($_POST['idcuentaesp'])) {
             $cesp0 = $this->cuenta_especial->get($_POST['idcuentaesp']);
         }
         if (!$cesp0) {
             $cesp0 = new cuenta_especial();
             $cesp0->idcuentaesp = $_POST['idcuentaesp'];
         }
         $cesp0->descripcion = $_POST['descripcion'];
         if ($cesp0->save()) {
             $this->new_message('Datos guardados correctamente.');
         } else {
             $this->new_error_msg('Imposible guardar los datos.');
         }
     } else {
         if (isset($_GET['delete'])) {
             $cesp0 = $this->cuenta_especial->get($_GET['delete']);
             if ($cesp0) {
                 if ($cesp0->delete()) {
                     $this->new_message('Identificador ' . $_GET['delete'] . ' eliminado correctamente.');
                 } else {
                     $this->new_error_msg('Imposible eliminar los datos.');
                 }
             }
         }
     }
 }
 public function cuentas_especiales()
 {
     $cuentae = new cuenta_especial();
     return $cuentae->all();
 }
 private function importar_xml()
 {
     $import_step = 0;
     $this->importar_url = FALSE;
     if (isset($_POST['fuente'])) {
         if (file_exists('tmp/' . FS_TMP_NAME . 'ejercicio.xml')) {
             unlink('tmp/' . FS_TMP_NAME . 'ejercicio.xml');
         }
         if ($_POST['fuente'] == 'archivo' and isset($_POST['archivo'])) {
             if (copy($_FILES['farchivo']['tmp_name'], 'tmp/' . FS_TMP_NAME . 'ejercicio.xml')) {
                 $import_step = 1;
                 $this->importar_url = $this->url() . '&importar=' . (1 + $import_step);
             } else {
                 $this->new_error_msg('Error al copiar el archivo.');
             }
         } else {
             if ($_POST['fuente'] != '') {
                 if (copy($_POST['fuente'], 'tmp/' . FS_TMP_NAME . 'ejercicio.xml')) {
                     $import_step = 1;
                     $this->importar_url = $this->url() . '&importar=' . (1 + $import_step);
                 } else {
                     $this->new_error_msg('Error al copiar el archivo.');
                 }
             } else {
                 $this->new_error_msg('Has seleccionado importar desde un archivo externo,
            pero no has seleccionado ningún archivo.');
             }
         }
     } else {
         if (isset($_GET['importar'])) {
             $import_step = intval($_GET['importar']);
             if ($import_step < 7) {
                 $this->importar_url = $this->url() . '&importar=' . (1 + $import_step);
             } else {
                 $this->new_advice('Datos importados correctamente &nbsp; <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>');
                 $import_step = 0;
             }
         }
     }
     if (file_exists('tmp/' . FS_TMP_NAME . 'ejercicio.xml') and $import_step > 0) {
         $offset = 0;
         if (isset($_GET['offset'])) {
             $offset = intval($_GET['offset']);
         }
         if ($offset == 0) {
             $this->new_message('Importando ejercicio: paso ' . $import_step . ' de 6 ...');
         } else {
             $this->new_message('Importando ejercicio: paso ' . $import_step . '.' . $offset / 1000 . ' de 6 ...');
         }
         $xml = simplexml_load_file('tmp/' . FS_TMP_NAME . 'ejercicio.xml');
         if ($xml) {
             if ($xml->balance and $import_step == 1) {
                 foreach ($xml->balance as $b) {
                     $balance = new balance();
                     if (!$balance->get($b->codbalance)) {
                         $balance->codbalance = $b->codbalance;
                         $balance->naturaleza = $b->naturaleza;
                         $balance->nivel1 = $b->nivel1;
                         $balance->descripcion1 = base64_decode($b->descripcion1);
                         $balance->nivel2 = $balance->intval($b->nivel2);
                         $balance->descripcion2 = base64_decode($b->descripcion2);
                         $balance->nivel3 = $b->nivel3;
                         $balance->descripcion3 = base64_decode($b->descripcion3);
                         $balance->orden3 = $b->orden3;
                         $balance->nivel4 = $b->nivel4;
                         $balance->descripcion4 = base64_decode($b->descripcion4);
                         $balance->descripcion4ba = base64_decode($b->descripcion4ba);
                         if (!$balance->save()) {
                             $this->importar_url = FALSE;
                         }
                     }
                 }
                 if ($xml->balance_cuenta) {
                     $balance_cuenta = new balance_cuenta();
                     $all_bcs = $balance_cuenta->all();
                     foreach ($xml->balance_cuenta as $bc) {
                         $encontrado = FALSE;
                         foreach ($all_bcs as $bc2) {
                             if ($bc2->codbalance == $bc->codbalance and $bc2->codcuenta == $bc->codcuenta) {
                                 $encontrado = TRUE;
                                 break;
                             }
                         }
                         if (!$encontrado) {
                             $new_bc = new balance_cuenta();
                             $new_bc->codbalance = $bc->codbalance;
                             $new_bc->codcuenta = $bc->codcuenta;
                             $new_bc->desccuenta = base64_decode($bc->descripcion);
                             if (!$new_bc->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
                 if ($xml->balance_cuenta_a) {
                     $balance_cuenta_a = new balance_cuenta_a();
                     $all_bcas = $balance_cuenta_a->all();
                     foreach ($xml->balance_cuenta_a as $bc) {
                         $encontrado = FALSE;
                         foreach ($all_bcas as $bc2) {
                             if ($bc2->codbalance == $bc->codbalance and $bc2->codcuenta == $bc->codcuenta) {
                                 $encontrado = TRUE;
                                 break;
                             }
                         }
                         if (!$encontrado) {
                             $new_bc = new balance_cuenta_a();
                             $new_bc->codbalance = $bc->codbalance;
                             $new_bc->codcuenta = $bc->codcuenta;
                             $new_bc->desccuenta = base64_decode($bc->descripcion);
                             if (!$new_bc->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
             }
             if ($import_step == 2) {
                 if ($xml->cuenta_especial) {
                     foreach ($xml->cuenta_especial as $ce) {
                         $cuenta_especial = new cuenta_especial();
                         if (!$cuenta_especial->get($ce->idcuentaesp)) {
                             $cuenta_especial->idcuentaesp = $ce->idcuentaesp;
                             $cuenta_especial->descripcion = base64_decode($ce->descripcion);
                             if (!$cuenta_especial->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
                 if ($xml->grupo_epigrafes) {
                     foreach ($xml->grupo_epigrafes as $ge) {
                         $grupo_epigrafes = new grupo_epigrafes();
                         if (!$grupo_epigrafes->get_by_codigo($ge->codgrupo, $this->ejercicio->codejercicio)) {
                             $grupo_epigrafes->codejercicio = $this->ejercicio->codejercicio;
                             $grupo_epigrafes->codgrupo = $ge->codgrupo;
                             $grupo_epigrafes->descripcion = base64_decode($ge->descripcion);
                             if (!$grupo_epigrafes->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
                 if ($xml->epigrafe) {
                     $grupo_epigrafes = new grupo_epigrafes();
                     foreach ($xml->epigrafe as $ep) {
                         $epigrafe = new epigrafe();
                         if (!$epigrafe->get_by_codigo($ep->codepigrafe, $this->ejercicio->codejercicio)) {
                             $ge = $grupo_epigrafes->get_by_codigo($ep->codgrupo, $this->ejercicio->codejercicio);
                             if ($ge) {
                                 /// si encuentra el grupo, lo añade con el grupo
                                 $epigrafe->idgrupo = $ge->idgrupo;
                                 $epigrafe->codgrupo = $ge->codgrupo;
                                 $epigrafe->codejercicio = $this->ejercicio->codejercicio;
                                 $epigrafe->codepigrafe = $ep->codepigrafe;
                                 $epigrafe->descripcion = base64_decode($ep->descripcion);
                                 if (!$epigrafe->save()) {
                                     $this->importar_url = FALSE;
                                 }
                             } else {
                                 if ($ep->codpadre) {
                                     $padre = $epigrafe->get_by_codigo($ep->codpadre, $this->ejercicio->codejercicio);
                                     if ($padre) {
                                         /// si encuentra al padre, lo añade con el padre
                                         $epigrafe->idpadre = $padre->idepigrafe;
                                         $epigrafe->codejercicio = $this->ejercicio->codejercicio;
                                         $epigrafe->codepigrafe = $ep->codepigrafe;
                                         $epigrafe->descripcion = base64_decode($ep->descripcion);
                                         if (!$epigrafe->save()) {
                                             $this->importar_url = FALSE;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if ($xml->cuenta and $import_step == 3) {
                 $epigrafe = new epigrafe();
                 foreach ($xml->cuenta as $c) {
                     $cuenta = new cuenta();
                     if (!$cuenta->get_by_codigo($c->codcuenta, $this->ejercicio->codejercicio)) {
                         $ep = $epigrafe->get_by_codigo($c->codepigrafe, $this->ejercicio->codejercicio);
                         if ($ep) {
                             $cuenta->idepigrafe = $ep->idepigrafe;
                             $cuenta->codepigrafe = $ep->codepigrafe;
                             $cuenta->codcuenta = $c->codcuenta;
                             $cuenta->codejercicio = $this->ejercicio->codejercicio;
                             $cuenta->descripcion = base64_decode($c->descripcion);
                             $cuenta->idcuentaesp = $c->idcuentaesp;
                             if (!$cuenta->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
             }
             if ($xml->subcuenta and $import_step == 4) {
                 $cuenta = new cuenta();
                 foreach ($xml->subcuenta as $sc) {
                     $subcuenta = new subcuenta();
                     if (!$subcuenta->get_by_codigo($sc->codsubcuenta, $this->ejercicio->codejercicio)) {
                         $cu = $cuenta->get_by_codigo($sc->codcuenta, $this->ejercicio->codejercicio);
                         if ($cu) {
                             $subcuenta->idcuenta = $cu->idcuenta;
                             $subcuenta->codcuenta = $cu->codcuenta;
                             $subcuenta->coddivisa = $this->empresa->coddivisa;
                             if (isset($sc->coddivisa)) {
                                 $subcuenta->coddivisa = $sc->coddivisa;
                             }
                             $subcuenta->codejercicio = $this->ejercicio->codejercicio;
                             $subcuenta->codsubcuenta = $sc->codsubcuenta;
                             $subcuenta->descripcion = base64_decode($sc->descripcion);
                             if (!$subcuenta->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
             }
             if ($import_step == 5) {
                 $cliente = new cliente();
                 $clientes = $cliente->all($offset);
                 while ($clientes) {
                     foreach ($clientes as $cli) {
                         /// forzamos la generación y asociación de una subcuenta para el cliente
                         $cli->get_subcuenta($this->ejercicio->codejercicio);
                         $offset++;
                     }
                     if ($offset % 1000 == 0) {
                         /// cada 1000 clientes volvemos a recargar la página para continuar
                         $this->importar_url = $this->url() . '&importar=' . $import_step . '&offset=' . $offset;
                         break;
                     } else {
                         $clientes = $cliente->all($offset);
                     }
                 }
             }
             if ($import_step == 6) {
                 $proveedor = new proveedor();
                 $proveedores = $proveedor->all($offset);
                 while ($proveedores) {
                     foreach ($proveedores as $pro) {
                         /// forzamos la generación y asociación de una subcuenta para cada proveedor
                         $pro->get_subcuenta($this->ejercicio->codejercicio);
                         $offset++;
                     }
                     if ($offset % 1000 == 0) {
                         /// cada 1000 proveedores volvemos a recargar la página para continuar
                         $this->importar_url = $this->url() . '&importar=' . $import_step . '&offset=' . $offset;
                         break;
                     } else {
                         $proveedores = $proveedor->all($offset);
                     }
                 }
             }
         } else {
             $this->new_error("Imposible leer el archivo.");
         }
     }
 }
 public function impuestos()
 {
     $tratamiento = false;
     $impuestos = new impuesto();
     //Eliminamos los Impuestos que no son de RD
     $lista_impuestos = array();
     foreach ($this->impuestos_rd as $imp) {
         $lista_impuestos[] = $imp['porcentaje'];
     }
     foreach ($impuestos->all() as $imp) {
         if (!in_array($imp->iva, $lista_impuestos)) {
             $imp->delete();
         }
     }
     //Agregamos los Impuestos de RD
     foreach ($this->impuestos_rd as $imp) {
         if (!$impuestos->get_by_iva($imp['porcentaje'])) {
             $imp0 = new impuesto();
             $imp0->codimpuesto = $imp['codigo'];
             $imp0->descripcion = $imp['descripcion'];
             $imp0->iva = $imp['porcentaje'];
             $imp0->recargo = $imp['recargo'];
             $imp0->codsubcuentasop = $imp['subcuenta_compras'];
             $imp0->codsubcuentarep = $imp['subcuenta_ventas'];
             if ($imp0->save()) {
                 $tratamiento = true;
             }
         }
     }
     //Corregimos la información de las Cuentas especiales con los nombres correctos
     $cuentas_especiales_rd['IVAACR'] = 'Cuentas acreedoras de ITBIS en la regularización';
     $cuentas_especiales_rd['IVASOP'] = 'Cuentas de ITBIS Compras';
     $cuentas_especiales_rd['IVARXP'] = 'Cuentas de ITBIS exportaciones';
     $cuentas_especiales_rd['IVASIM'] = 'Cuentas de ITBIS importaciones';
     $cuentas_especiales_rd['IVAREX'] = 'Cuentas de ITBIS para clientes exentos';
     $cuentas_especiales_rd['IVAREP'] = 'Cuentas de ITBIS Ventas';
     $cuentas_especiales = new cuenta_especial();
     foreach ($cuentas_especiales_rd as $id => $desc) {
         $linea = $cuentas_especiales->get($id);
         if ($linea->descripcion !== $desc) {
             $linea->descripcion = $desc;
             $linea->save();
         }
     }
     if ($tratamiento) {
         $this->new_message('Información de impuestos actualizada correctamente');
     } else {
         $this->new_message('No se modificaron datos de impuestos previamente tratados.');
     }
 }
Example #6
0
 public function all()
 {
     $culist = array();
     $data = $this->db->select("SELECT * FROM " . $this->table_name . " ORDER BY descripcion ASC;");
     if ($data) {
         foreach ($data as $c) {
             $culist[] = new cuenta_especial($c);
         }
     }
     /// comprobamos la de acreedores
     $encontrada = FALSE;
     foreach ($culist as $ce) {
         if ($ce->idcuentaesp == 'ACREED') {
             $encontrada = TRUE;
         }
     }
     if (!$encontrada) {
         $ce = new cuenta_especial();
         $ce->idcuentaesp = 'ACREED';
         $ce->descripcion = 'Cuentas de acreedores';
         if ($ce->save()) {
             $culist[] = $ce;
         }
     }
     return $culist;
 }
 private function importar_xml()
 {
     $import_step = 0;
     $this->importar_url = FALSE;
     if (isset($_POST['fuente'])) {
         if (file_exists('tmp/' . FS_TMP_NAME . 'ejercicio.xml')) {
             unlink('tmp/' . FS_TMP_NAME . 'ejercicio.xml');
         }
         if (in_array($_POST['fuente'], array('espanya', 'colombia', 'panama', 'peru', 'venezuela'))) {
             copy('extras/' . $_POST['fuente'] . '.xml', 'tmp/' . FS_TMP_NAME . 'ejercicio.xml');
         } else {
             if ($_POST['fuente'] == 'archivo' and isset($_POST['archivo'])) {
                 copy($_FILES['farchivo']['tmp_name'], 'tmp/' . FS_TMP_NAME . 'ejercicio.xml');
             } else {
                 $this->new_error_msg('Has seleccionado importar desde un archivo externo,
            pero no has seleccionado ningún archivo.');
             }
         }
         $import_step = 1;
         $this->importar_url = $this->url() . '&importar=' . (1 + $import_step);
     } else {
         if (isset($_GET['importar'])) {
             $import_step = intval($_GET['importar']);
             if ($import_step < 7) {
                 $this->importar_url = $this->url() . '&importar=' . (1 + $import_step);
             } else {
                 $this->new_message('Datos importados correctamente.');
                 $this->new_message("Ahora es el momento de <a href='index.php?page=ventas_clientes#nuevo'>" . "añadir algún cliente</a>, si todavía no lo has hecho.");
                 $import_step = 0;
             }
         }
     }
     if (file_exists('tmp/' . FS_TMP_NAME . 'ejercicio.xml') and $import_step > 0) {
         $this->new_message('Importando ejercicio: paso ' . $import_step . ' de 6 ...');
         $xml = simplexml_load_file('tmp/' . FS_TMP_NAME . 'ejercicio.xml');
         if ($xml) {
             if ($xml->balance and $import_step == 1) {
                 foreach ($xml->balance as $b) {
                     $balance = new balance();
                     if (!$balance->get($b->codbalance)) {
                         $balance->codbalance = $b->codbalance;
                         $balance->naturaleza = $b->naturaleza;
                         $balance->nivel1 = $b->nivel1;
                         $balance->descripcion1 = base64_decode($b->descripcion1);
                         $balance->nivel2 = $balance->intval($b->nivel2);
                         $balance->descripcion2 = base64_decode($b->descripcion2);
                         $balance->nivel3 = $b->nivel3;
                         $balance->descripcion3 = base64_decode($b->descripcion3);
                         $balance->orden3 = $b->orden3;
                         $balance->nivel4 = $b->nivel4;
                         $balance->descripcion4 = base64_decode($b->descripcion4);
                         $balance->descripcion4ba = base64_decode($b->descripcion4ba);
                         if (!$balance->save()) {
                             $this->importar_url = FALSE;
                         }
                     }
                 }
                 if ($xml->balance_cuenta) {
                     $balance_cuenta = new balance_cuenta();
                     $all_bcs = $balance_cuenta->all();
                     foreach ($xml->balance_cuenta as $bc) {
                         $encontrado = FALSE;
                         foreach ($all_bcs as $bc2) {
                             if ($bc2->codbalance == $bc->codbalance and $bc2->codcuenta == $bc->codcuenta) {
                                 $encontrado = TRUE;
                                 break;
                             }
                         }
                         if (!$encontrado) {
                             $new_bc = new balance_cuenta();
                             $new_bc->codbalance = $bc->codbalance;
                             $new_bc->codcuenta = $bc->codcuenta;
                             $new_bc->desccuenta = base64_decode($bc->descripcion);
                             if (!$new_bc->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
                 if ($xml->balance_cuenta_a) {
                     $balance_cuenta_a = new balance_cuenta_a();
                     $all_bcas = $balance_cuenta_a->all();
                     foreach ($xml->balance_cuenta_a as $bc) {
                         $encontrado = FALSE;
                         foreach ($all_bcas as $bc2) {
                             if ($bc2->codbalance == $bc->codbalance and $bc2->codcuenta == $bc->codcuenta) {
                                 $encontrado = TRUE;
                                 break;
                             }
                         }
                         if (!$encontrado) {
                             $new_bc = new balance_cuenta_a();
                             $new_bc->codbalance = $bc->codbalance;
                             $new_bc->codcuenta = $bc->codcuenta;
                             $new_bc->desccuenta = base64_decode($bc->descripcion);
                             if (!$new_bc->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
             }
             if ($import_step == 2) {
                 if ($xml->cuenta_especial) {
                     foreach ($xml->cuenta_especial as $ce) {
                         $cuenta_especial = new cuenta_especial();
                         if (!$cuenta_especial->get($ce->idcuentaesp)) {
                             $cuenta_especial->idcuentaesp = $ce->idcuentaesp;
                             $cuenta_especial->descripcion = base64_decode($ce->descripcion);
                             if (!$cuenta_especial->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
                 if ($xml->grupo_epigrafes) {
                     foreach ($xml->grupo_epigrafes as $ge) {
                         $grupo_epigrafes = new grupo_epigrafes();
                         if (!$grupo_epigrafes->get_by_codigo($ge->codgrupo, $this->ejercicio->codejercicio)) {
                             $grupo_epigrafes->codejercicio = $this->ejercicio->codejercicio;
                             $grupo_epigrafes->codgrupo = $ge->codgrupo;
                             $grupo_epigrafes->descripcion = base64_decode($ge->descripcion);
                             if (!$grupo_epigrafes->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
                 if ($xml->epigrafe) {
                     $grupo_epigrafes = new grupo_epigrafes();
                     foreach ($xml->epigrafe as $ep) {
                         $epigrafe = new epigrafe();
                         if (!$epigrafe->get_by_codigo($ep->codepigrafe, $this->ejercicio->codejercicio)) {
                             $ge = $grupo_epigrafes->get_by_codigo($ep->codgrupo, $this->ejercicio->codejercicio);
                             if ($ge) {
                                 $epigrafe->idgrupo = $ge->idgrupo;
                                 $epigrafe->codgrupo = $ge->codgrupo;
                                 $epigrafe->codejercicio = $this->ejercicio->codejercicio;
                                 $epigrafe->codepigrafe = $ep->codepigrafe;
                                 $epigrafe->descripcion = base64_decode($ep->descripcion);
                                 if (!$epigrafe->save()) {
                                     $this->importar_url = FALSE;
                                 }
                             }
                         }
                     }
                 }
             }
             if ($xml->cuenta and $import_step == 3) {
                 $epigrafe = new epigrafe();
                 foreach ($xml->cuenta as $c) {
                     $cuenta = new cuenta();
                     if (!$cuenta->get_by_codigo($c->codcuenta, $this->ejercicio->codejercicio)) {
                         $ep = $epigrafe->get_by_codigo($c->codepigrafe, $this->ejercicio->codejercicio);
                         if ($ep) {
                             $cuenta->idepigrafe = $ep->idepigrafe;
                             $cuenta->codepigrafe = $ep->codepigrafe;
                             $cuenta->codcuenta = $c->codcuenta;
                             $cuenta->codejercicio = $this->ejercicio->codejercicio;
                             $cuenta->descripcion = base64_decode($c->descripcion);
                             $cuenta->idcuentaesp = $c->idcuentaesp;
                             if (!$cuenta->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
             }
             if ($xml->subcuenta and $import_step == 4) {
                 $cuenta = new cuenta();
                 foreach ($xml->subcuenta as $sc) {
                     $subcuenta = new subcuenta();
                     if (!$subcuenta->get_by_codigo($sc->codsubcuenta, $this->ejercicio->codejercicio)) {
                         $cu = $cuenta->get_by_codigo($sc->codcuenta, $this->ejercicio->codejercicio);
                         if ($cu) {
                             $subcuenta->idcuenta = $cu->idcuenta;
                             $subcuenta->codcuenta = $cu->codcuenta;
                             $subcuenta->coddivisa = $sc->coddivisa;
                             $subcuenta->codejercicio = $this->ejercicio->codejercicio;
                             $subcuenta->codsubcuenta = $sc->codsubcuenta;
                             $subcuenta->descripcion = base64_decode($sc->descripcion);
                             if (!$subcuenta->save()) {
                                 $this->importar_url = FALSE;
                             }
                         }
                     }
                 }
             }
             if ($import_step == 5) {
                 $cliente = new cliente();
                 foreach ($cliente->all_full() as $cli) {
                     /// forzamos la generación y asociación de una subcuenta para el cliente
                     $cli->get_subcuenta($this->ejercicio->codejercicio);
                 }
             }
             if ($import_step == 6) {
                 $proveedor = new proveedor();
                 foreach ($proveedor->all_full() as $pro) {
                     /// forzamos la generación y asociación de una subcuenta para cada proveedor
                     $pro->get_subcuenta($this->ejercicio->codejercicio);
                 }
             }
         } else {
             $this->new_error("Imposible leer el archivo.");
         }
     }
 }