function setPolizaPorRecibo($recibo, $generador = false) { $sucess = false; $QL = new MQL(); $xLogg = new cCoreLog(); //$arrEquivEfvo = //if (GENERAR_CONTABILIDAD == true){ $xLogg->add("=======\tGENERAR POLIZA POR RECIBO NUM {$recibo}\r\n", $xLogg->DEVELOPER); $xT = new cCatalogoOperacionesDeCaja(); $centro_de_costo = DEFAULT_CENTRO_DE_COSTO; //($generador == GENERAR_POLIZAS_AL_CIERRE) AND if (setNoMenorQueCero($recibo) > 0) { $xRec = new cReciboDeOperacion(false, false, $recibo); if ($xRec->init() == true) { $sucess = true; //Obten datos del recibo para la Poliza $sqlRec = "SELECT\r\n\t\t\t\t\t\t\t`operaciones_recibos`.*,\r\n\t\t\t\t\t\t\t`operaciones_recibostipo`.`tipo_poliza_generada`,\r\n\t\t\t\t\t\t`operaciones_recibostipo`.`afectacion_en_flujo_efvo`\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t`operaciones_recibos` `operaciones_recibos`\r\n\t\t\t\t\t\t\t\tINNER JOIN `operaciones_recibostipo`\r\n\t\t\t\t\t\t\t\t`operaciones_recibostipo`\r\n\t\t\t\t\t\t\t\tON `operaciones_recibos`.`tipo_docto` =\r\n\t\t\t\t\t\t\t\t`operaciones_recibostipo`.\r\n\t\t\t\t\t\t\t\t`idoperaciones_recibostipo`\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t(`operaciones_recibos`.`idoperaciones_recibos` = {$recibo})\r\n\t\t\t\t\t\tLIMIT 0,1 "; $dRec = obten_filas($sqlRec); $tipo_de_pago = $xRec->getTipoDePago(); //Corrige los cargos de la PolizaS $total_poliza = 0; $SQLSumCargos = "SELECT SUM(monto) AS 'total' FROM contable_polizas_proforma\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE contable_operacion = '" . TM_CARGO . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND numero_de_recibo={$recibo} "; $TMPCargos = mifila($SQLSumCargos, "total"); $SQLSumAbonos = "SELECT SUM(monto) AS 'total' FROM contable_polizas_proforma\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE contable_operacion = '" . TM_ABONO . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND numero_de_recibo={$recibo} "; $TMPAbonos = mifila($SQLSumAbonos, "total"); if ($TMPCargos > $TMPAbonos) { $diferencia = $TMPAbonos - $TMPCargos; $diferencia = $diferencia < 0 ? $diferencia * -1 : $diferencia; $total_poliza = $TMPCargos; setPolizaProforma($recibo, $xT->getTipoOperacionByTipoPago($tipo_de_pago), $diferencia, 1, 1, TM_ABONO); $xLogg->add("OK\tCUADRAR\tABONO\tOperacion Agregada por DESCUADRE en {$tipo_de_pago} por {$diferencia}\r\n", $xLogg->DEVELOPER); //$xLogg->add( , $xLogg->DEVELOPER); } elseif ($TMPCargos < $TMPAbonos) { $diferencia = $TMPCargos - $TMPAbonos; $diferencia = $diferencia < 0 ? $diferencia * -1 : $diferencia; $total_poliza = $TMPAbonos; setPolizaProforma($recibo, $xT->getTipoOperacionByTipoPago($tipo_de_pago), $diferencia, 1, 1, TM_CARGO); $xLogg->add("OK\tCUADRAR\tCARGOS\tOperacion Agregada por DESCUADRE en {$tipo_de_pago} por {$diferencia}\r\n", $xLogg->DEVELOPER); } else { $total_poliza = $TMPCargos; } //tipos de Poliza 1=ingreso, 2=egreso, 3 Diario, 4=orden 5 $xD = new cFecha(0, $xRec->getFechaDeRecibo()); $numero_de_recibo = $recibo; $tipo_de_poliza = $xRec->getOTipoRecibo()->getTipoPolizaContable(); $fecha_de_poliza = $xRec->getFechaDeRecibo(); $ejercicio_de_poliza = $xD->anno(); $periodo_de_poliza = $xD->mes(); $recibo_fiscal = strlen($xRec->getReciboFiscal()) > 2 ? ";RF:" . $xRec->getReciboFiscal() : ""; $observacion_recibo = $xRec->getObservaciones(); $cheque = strlen($xRec->getNumeroDeCheque()) > 2 ? ";Ch:" . $xRec->getNumeroDeCheque() : ""; $concepto_poliza = substr("R:" . $numero_de_recibo . $recibo_fiscal . $cheque . ";" . $xRec->getObservaciones(), 0, 80); $flujo_efectivo = $xRec->getOTipoRecibo()->getAfectacionEnEfvo(); $socio = $xRec->getCodigoDeSocio(); $propietario = $xRec->getCodigoDeUsuario(); $xLogg->add("=====\tRECIBO TIPO: " . $xRec->getTipoDeRecibo() . " SUMA: " . $xRec->getTotal() . " \r\n", $xLogg->DEVELOPER); //------------------ Agregar Poliza $xPol = new cPoliza($tipo_de_poliza, false, $ejercicio_de_poliza, $periodo_de_poliza); $xPol->add($concepto_poliza, $fecha_de_poliza, false, 0, 0, $propietario, $centro_de_costo, $recibo); $numero_de_poliza = $xPol->get(); $xLogg->add("=====\tPOLIZA NUM: {$numero_de_poliza} | TIPO: {$tipo_de_poliza} | EJERCICIO: {$ejercicio_de_poliza} | PERIODO: {$periodo_de_poliza}\r\n", $xLogg->DEVELOPER); $sucess = $xPol->mRaiseError == true ? false : true; //------------------ Leer la PROFORMA $sqlMvtosToPoliza = "SELECT\r\n\t\t\t\t\t`contable_polizas_proforma`.*,\r\n\t\t\t\t\t`operaciones_tipos`.*\r\n\t\t\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t`operaciones_tipos` `operaciones_tipos`\r\n\t\t\t\t\t\tINNER JOIN `contable_polizas_proforma`\r\n\t\t\t\t\t\t`contable_polizas_proforma`\r\n\t\t\t\t\t\tON `operaciones_tipos`.`idoperaciones_tipos` =\r\n\t\t\t\t\t\t`contable_polizas_proforma`.`tipo_de_mvto`\r\n\t\t\t\t\t\tAND `contable_polizas_proforma`.`numero_de_recibo` = {$numero_de_recibo}\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t`contable_polizas_proforma`.`contable_operacion` DESC,\r\n\t\t\t\t\t\t`contable_polizas_proforma`.`socio`,\r\n\t\t\t\t\t\t`contable_polizas_proforma`.`tipo_de_mvto`\t\t\t\t\r\n\t\t\t\t\t"; if ($sucess == true) { $rs = $QL->getDataRecord($sqlMvtosToPoliza); foreach ($rs as $rw) { $cuenta = CUENTA_DE_CUADRE; $nombre = ""; $socio = $rw["socio"]; if (CONTABLE_CUENTAS_POR_SOCIO == true) { $xSoc = new cSocio($socio, true); $nombre = $xSoc->getNombreCompleto(); } $documento = $rw["documento"]; $monto_movimiento = $rw["monto"]; $tipoOp = $rw["tipo_de_mvto"]; $tipo_movimiento = $rw["contable_operacion"]; $RecUsr = $rw["idusuario"]; $cuenta_bancaria = $rw["banco"]; $cargo_movimiento = 0; $abono_movimiento = 0; if ($tipo_movimiento == TM_CARGO) { $cargo_movimiento = $monto_movimiento; $abono_movimiento = 0; } else { $cargo_movimiento = 0; $abono_movimiento = $monto_movimiento; } $formula = $rw["cuenta_contable"]; //Corregir de urgencia: OK: 06Oct2011 $sForms = new cValorarFormulas(); $cuenta = $sForms->getCuentaContable($socio, $documento, $formula, $RecUsr, $xRec->getNumeroDeCheque(), $cuenta_bancaria); $xLogg->add($sForms->getMessages(), $xLogg->DEVELOPER); //tipo de cuenta es Abonos a efectivo if ($cuenta != "NO_CONTABILIZAR") { $xCuenta = new cCuentaContable($cuenta); $xCuenta->init(); $cuenta = $xCuenta->get(); //Carga los datos del Oficial if ($xCuenta->getEsCuentaDeCirculante() == true) { $xOf = new cSystemUser($RecUsr); $xOf->init(); $nombre = $xOf->getNombreCompleto(); $xLogg->add("OK\tCUENTA_ADD\tLa Cuenta {$cuenta} de Carga por Usuario [ {$nombre} ]\r\n", $xLogg->DEVELOPER); } else { $xLogg->add("OK\tCUENTA\tLa Cuenta de Trabajo es {$cuenta} Originado del Socio {$socio}\r\n", $xLogg->DEVELOPER); } //verifica para dar de alta a la cuenta $Existentes = $xCuenta->getCountCuenta(); if ($Existentes == false) { $xLogg->add("WARN\tCUENTA_ADD\tLa Cuenta de Trabajo {$cuenta} NO EXISTE, se AGREGA\r\n", $xLogg->DEVELOPER); $cuenta = $xCuenta->add($nombre); if ($xCuenta->mRaiseError == true) { //$msg .= "ERROR\tLa Cuenta de Trabajo $cuenta NO EXISTE\r\n"; //$msg = $xCuenta->getMessages(); } } $xCuenta->init(); $xPol->addMovimiento($cuenta, $cargo_movimiento, $abono_movimiento, "{$socio}", "{$documento}:{$tipoOp}", false, $fecha_de_poliza); //$xLogg->add("WARN\tNO_CONT\tAGREGAR $cuenta, $cargo_movimiento, $abono_movimiento\r\n" , $xLogg->DEVELOPER); $xLogg->add($xCuenta->getMessages(), $xLogg->DEVELOPER); } else { $xLogg->add("WARN\tNO_CONT\tEl Movimiento de {$socio} | {$documento} | {$tipoOp} de Monto {$monto_movimiento} se OMITE\r\n", $xLogg->DEVELOPER); } } $xPol->setFinalizar(); } //sucess $xLogg->add($xPol->getMessages(), $xLogg->DEVELOPER); $this->mIDDePoliza = $xPol->getCodigo(); } } //END VALUE.- GENERAR AL FINAL //} //END VALUE.- GENERAR CONTABILIDAD $this->mMessages .= $xLogg->getMessages(); return $xLogg->getMessages(); }
$xSoc->init(); $xCred = $xRec->getCredito(); $xCred->init(); $xF = new cFecha(); $idsocio = $xSoc->getCodigo(); //"numero_socio" $idsolicitud = $xRec->getCodigoDeDocumento(); // docto_afectado $nombre = $xSoc->getNombreCompleto(); // ------------------------------------ DATOS DE LA SOLICITUD. $tasa_ahorro = $xCred->getTasaDeAhorro() * 100; $tasa_interes = $xCred->getTasaDeInteres() * 100; $dias_totales = $xCred->getDiasAutorizados(); $numero_pagos = $xCred->getPagosAutorizados(); $nombre_otro = ""; $observaciones = $xRec->getObservaciones(); $extTool = ""; echo $xSoc->getFicha(); echo $xCred->getFicha(true, "", false); $pagoactual = $xCred->getPeriodoActual(); if ($ShowAvales == true) { $avals = $xCred->getAvales_InText(); echo $avals; } //------------------------------------- DATOS DEL RECIBO $sumrec = $xRec->getTotal(); $sql = "\n\t\t\tSELECT operaciones_mvtos.periodo_socio AS 'parcialidad', fecha_afectacion,\n\t\t\t\t\toperaciones_tipos.idoperaciones_tipos As 'tipo',\n\t\t\t\t\toperaciones_tipos.descripcion_operacion AS 'concepto' ,\n\t\t\t\t\toperaciones_mvtos.afectacion_real AS 'monto',\n\t\t\t\t\toperaciones_mvtos.saldo_actual AS 'saldo',\n\t\t\t\t\toperaciones_mvtos.valor_afectacion AS 'afectacion'\n\t\t\tFROM \t`operaciones_mvtos` `operaciones_mvtos`\n\t\t\t\t\tINNER JOIN `operaciones_tipos` `operaciones_tipos`\n\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = `operaciones_tipos`.\n\t\t\t\t\t`idoperaciones_tipos`\n\n\t\t\tWHERE operaciones_mvtos.recibo_afectado={$idrecibo}\n\t\t\tORDER BY operaciones_mvtos.periodo_socio, operaciones_tipos.idoperaciones_tipos"; $rs = $ql->getDataRecord($sql); $trs = ""; //Parcialidad, evaluador de inciio y final $PInit = 0;
function setRecibo($recibo) { $xRec = new cReciboDeOperacion(false, false, $recibo); if ($xRec->init() == true) { $this->setPersona($xRec->getCodigoDeSocio()); $OTipo = $xRec->getOTipoRecibo(); $origen = $OTipo->getOrigen(); $afectEfvo = $OTipo->getAfectacionEnEfvo(); $xCant = new cCantidad($xRec->getTotal()); $QL = new MQL(); $xF = new cFecha(); $describe = ""; $xCta = null; $xCred = null; //Bases de Operaciones de Captacion en Inversiones $xB3100 = new cBases(3100); $DB3100 = $xB3100->getMembers_InArray(); $xB3200 = new cBases(3200); $DB3200 = $xB3200->getMembers_InArray(); switch ($origen) { case RECIBOS_ORIGEN_MIXTO: $this->setCredito($xRec->getCodigoDeDocumento()); break; case RECIBOS_ORIGEN_COLOCACION: $this->setCredito($xRec->getCodigoDeDocumento()); break; case RECIBOS_ORIGEN_CAPTACION: $this->setCuentaDeCaptacion($xRec->getCodigoDeDocumento()); break; } $this->mArr["variable_tipo_de_recibo"] = $OTipo->getNombre(); $this->mArr["variable_datos_del_pago"] = $xRec->getDatosDeCobro(); $this->mArr["variable_numero_de_recibo"] = $recibo; $this->mArr["variable_docto_fecha_larga_actual"] = $xF->getFechaLarga($xRec->getFechaDeRecibo()); $this->mArr["variable_observacion_del_recibo"] = $xRec->getObservaciones(); $this->mArr["variable_monto_del_recibo_en_letras"] = $xCant->letras(); $this->mArr["variable_monto_del_recibo"] = $xCant->moneda(); ///$this->mArr["variable_nombre_del_cajero"] = $xRec->getOUsuario()->getNombreCompleto(); $this->mEsRecibo = true; $this->setUsuario($xRec->getCodigoDeUsuario()); //obtener operaciones $this->mRecibo = $recibo; $sqlmvto = "SELECT\n\t\t\t`operaciones_mvtos`.`socio_afectado` AS `numero_de_socio`,\n\t\t\t`operaciones_mvtos`.`docto_afectado` AS `numero_de_documento`,\n\t\t\t`operaciones_mvtos`.`recibo_afectado` AS `numero_de_recibo`,\n\t\t\t`operaciones_mvtos`.`idoperaciones_mvtos` AS `numero_del_movimiento`,\n\t\t\t`operaciones_tipos`.`descripcion_operacion` AS `concepto_del_movimiento`,\n\t\t\t`operaciones_mvtos`.`afectacion_real` AS `monto_del_movimiento`,\n\t\t\t`operaciones_mvtos`.`valor_afectacion` AS `naturaleza_del_movimiento`,\n\t\t\t`operaciones_tipos`.`nombre_corto` \t\t\tAS `concepto_nombre_corto`,\n\t\t\t`operaciones_mvtos`.`periodo_socio` \tAS `parcialidad`,\n\t\t\t`operaciones_mvtos`.`detalles` \t\t\t\tAS `observacion_del_mvto`,\n\t\t\t`operaciones_mvtos`.`tipo_operacion`\t\tAS `tipo_de_movimiento`\n\t\t\tFROM\n\t\t\t`operaciones_mvtos` `operaciones_mvtos`\tINNER JOIN `operaciones_tipos` `operaciones_tipos` ON `operaciones_mvtos`.`tipo_operacion` = `operaciones_tipos`.`idoperaciones_tipos`\n\t\t\tWHERE (`operaciones_mvtos`.`recibo_afectado` = {$recibo} ) ORDER BY `operaciones_mvtos`.`afectacion_real` DESC"; $rs = $QL->getDataRecord($sqlmvto); //destino_del_movimiento foreach ($rs as $row) { $rwx = $row; $tipo = $row["tipo_de_movimiento"]; $docto = $row["numero_de_documento"]; $rwx["monto_del_movimiento"] = getFMoney($row["monto_del_movimiento"] * $row["naturaleza_del_movimiento"] * $afectEfvo); $rwx["destino_del_movimiento"] = " " . $row["numero_de_documento"]; if (in_array($tipo, $DB3100) == true or in_array($tipo, $DB3200)) { if ($origen == RECIBOS_ORIGEN_MIXTO) { //TODO: Cargar datos de la cuenta de captacion y mostrar sus caracteristicas } else { //if($xCta == null){ $xCta = new cCuentaDeCaptacion($docto); $xCta->init(); } $rwx["destino_del_movimiento"] .= "|" . $this->mArr["variable_tipo_de_cuenta"]; } } else { $rwx["destino_del_movimiento"] .= "|" . substr($this->mArr["variable_tipo_de_credito"], 0, 5); $rwx["destino_del_movimiento"] .= "|" . substr($this->mArr["variable_estado_de_credito"], 0, 3); $rwx["destino_del_movimiento"] .= "|" . $row["parcialidad"] . "/" . $this->mArr["variable_credito_numero_de_pagos"]; } $this->mDataMvto[] = $rwx; } } }