// $dcredito["fecha_ministracion"]; $fecha_ult_mvto = $xCred->getFechaUltimoDePago(); $fecha_vencimiento = $xCred->getFechaDeVencimiento(); // $dcredito["fecha_vencimiento"]; $numero_de_pagos = $xCred->getPagosAutorizados(); $estatus_del_credito = $xCred->getEstadoActual(); $saldo_actual = $xCred->getSaldoActual(); $saldo_del_credito = $saldo_actual; $interes_anticipado = $dcredito["sdo_int_ant"]; $grupo = $xCred->getClaveDeGrupo(); $OProducto = $xCred->getOProductoDeCredito(); //$OEstado = $xCred->getOEstado(); $tasa_iva = $generarIVA == false ? 0 : $xCred->getTasaIVA(); $interes_normal_devengado = $xCred->getInteresNormalDevengado(); $interes_normal_pagado = $xCred->getInteresNormalPagado(); $interes_moratorio_pagado = $xCred->getInteresMoratorioPagado(); $interes_moratorio_devengado = $xCred->getInteresMoratorioDev(); $periocidad = $xCred->getPeriocidadDePago(); $ByLetra = ""; $solo_mora_corriente = $pago_total == true ? true : false; //Corrige calculo de Interes.- Si es primer pago $DInteres = $xCred->getInteresDevengado($fecha_operacion, $parcialidad, false, $solo_mora_corriente); $interes_normal_calculado = $DInteres[SYS_INTERES_NORMAL]; $interes_moratorio_calculado = $DInteres[SYS_INTERES_MORATORIO]; $gastos_de_cobranza_calculado = $DInteres[SYS_GASTOS_DE_COBRANZA]; $fecha_de_pago = $fecha_vencimiento; if ($xCred->getPeriocidadDePago() != CREDITO_TIPO_PERIOCIDAD_FINAL_DE_PLAZO) { $xLetra = new cParcialidadDeCredito(); if ($xLetra->init($xCred->getClaveDePersona(), $xCred->getNumeroDeCredito(), $parcialidad) == true) { $fecha_de_pago = $xLetra->getFechaDePago(); $xLog->add("OK\tFecha de Pago establecida a {$fecha_de_pago}\r\n", $xLog->DEVELOPER);
function calcular($fecha_inicial = false, $PrimerPago = false, $SegundoPago = false, $TercerPago = false) { $xCred = new cCredito($this->mClaveDeCredito); $xCred->init(); $xF = new cFecha(); $msg = ""; $FORMA_DE_PAGO = $xCred->getFormaDePago(); $PAGOS_AUTORIZADOS = $xCred->getPagosAutorizados(); $PERIOCIDAD_DE_PAGO = $xCred->getPeriocidadDePago(); $MONTO_AUTORIZADO = $xCred->getMontoAutorizado(); $SALDO_ACTUAL = $xCred->getSaldoActual(); $INTERES_PAGADO = $xCred->getInteresNormalPagado(); $MORA_PAGADO = $xCred->getInteresMoratorioPagado(); $xCred->initPagosEfectuados(); $CAPITAL_PAGADO = setNoMenorQueCero($MONTO_AUTORIZADO - $SALDO_ACTUAL); $SALDO_DE_PLAN = $xCred->getMontoAutorizado(); $TASA_NORMAL = $xCred->getTasaDeInteres(); $TASA_MORA = $xCred->getTasaDeMora(); $TASA_IVA = $xCred->getTasaIVA(); $DIVISOR_DE_INTS = EACP_DIAS_INTERES; $FECHA_DE_PAGO = $xCred->getFechaPrimeraParc(); $FECHA_INICIAL = $xCred->getFechaDeMinistracion(); $opciondia_1 = $PrimerPago; $opciondia_2 = $SegundoPago; $opciondia_3 = $TercerPago; //sanitiza la fecha de pago if ($FECHA_DE_PAGO == false) { $FECHA_DE_PAGO = $xF->setSumarDias($PERIOCIDAD_DE_PAGO, $FECHA_INICIAL); } if (($PERIOCIDAD_DE_PAGO > CREDITO_TIPO_PERIOCIDAD_CATORCENAL or $PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_CATORCENAL) and ($opciondia_1 == false or $opciondia_2 == false or $opciondia_3 == false)) { if ($PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_QUINCENAL) { $opciondia_1 = $opciondia_1 == false ? PQ_DIA_PRIMERA_QUINCENA : $opciondia_1; $opciondia_2 = $opciondia_2 == false ? PQ_DIA_SEGUNDA_QUINCENA : $opciondia_2; } elseif ($PERIOCIDAD_DE_PAGO == CREDITO_TIPO_PERIOCIDAD_DECENAL) { $opciondia_1 = $opciondia_1 == false ? 10 : $opciondia_1; $opciondia_2 = $opciondia_2 == false ? 20 : $opciondia_2; $opciondia_3 = $opciondia_3 == false ? 30 : $opciondia_3; } else { $opciondia_1 = $opciondia_1 == false ? PM_DIA_DE_PAGO : $opciondia_1; } } //pagos decenales entre el mes $arrPagos = array(); //obtener los dias de pago en el mes por tipo de pago $dia_de_pago = $xCred->getFechaDeMinistracion(); for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) { $letra = $i; switch ($PERIOCIDAD_DE_PAGO) { case CREDITO_TIPO_PERIOCIDAD_DIARIO: $dia_de_pago = $xF->getDiaHabil($xF->setSumarDias(1, $dia_de_pago)); $arrPagos[$letra][SYS_FECHA] = $dia_de_pago; $msg .= "OK\t{$letra}\tDIARIO\tFecha de pago a {$dia_de_pago}\r\n"; break; case CREDITO_TIPO_PERIOCIDAD_SEMANAL: break; case CREDITO_TIPO_PERIOCIDAD_DECENAL: break; case CREDITO_TIPO_PERIOCIDAD_CATORCENAL: //dias naturales, cada dos semanas? break; case CREDITO_TIPO_PERIOCIDAD_QUINCENAL: $dia_de_pago = $xF->setSumarDias(CREDITO_TIPO_PERIOCIDAD_QUINCENAL, $dia_de_pago); $dia_de_pago = $xF->getDiaAbonoQuincenal($opciondia_1, $opciondia_2, $dia_de_pago); $arrPagos[$letra][SYS_FECHA] = $dia_de_pago; $msg .= "OK\t{$letra}\tQUINCENAL\tFecha de pago a {$dia_de_pago}, opcion {$opciondia_1}, {$opciondia_2}\r\n"; break; case CREDITO_TIPO_PERIOCIDAD_MENSUAL: $dia_de_pago = date("Y-m-", $xF->getInt($dia_de_pago)) . $opciondia_1; $dia_de_pago = $xF->setSumarMeses(1, $dia_de_pago); $dia_de_pago = $xF->getDiaHabil($dia_de_pago); $arrPagos[$letra][SYS_FECHA] = $dia_de_pago; $msg .= "OK\t{$letra}\tMENSUAL\tFecha de pago a {$dia_de_pago}, opcion {$opciondia_1}\r\n"; break; case CREDITO_TIPO_PERIOCIDAD_BIMESTRAL: break; case CREDITO_TIPO_PERIOCIDAD_TRIMESTRAL: break; } } //$FORMULA_INT = new cFormula("interes_normal"); //dias de pago //si es empresa, tomar la fecha de la empresa semanal, quincenal, mensual, decenal //Iniciar los Pagos Actuales //$this->initParcsPendientes(); $DatosDePagados = $xCred->getListadoDePagos(); /* interes capital impuestos */ switch ($FORMA_DE_PAGO) { case CREDITO_TIPO_PAGO_PERIODICO: //parcialidad interes + capital break; case CREDITO_TIPO_PAGO_FLAT_PARCIAL: for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) { $letra = $i; $letraAnterior = setNoMenorQueCero($letra - 1); $PagoAnterior = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array(); $capital_pagado = isset($DPago[SYS_CAPITAL]) ? $DPago[SYS_CAPITAL] : 0; $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado; $interes_normal = $MONTO_AUTORIZADO * $PERIOCIDAD_DE_PAGO * $TASA_NORMAL / $DIVISOR_DE_INTS; $capital = $MONTO_AUTORIZADO / $PAGOS_AUTORIZADOS; $capital = setNoMenorQueCero($capital - $capital_pagado); $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0; $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado); $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal; if ($letra == $PAGOS_AUTORIZADOS) { if ($SALDO_DE_PLAN > 0) { $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN; $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n"; } } //determinar proxima fecha de pago $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado} \r\n"; } break; case CREDITO_TIPO_PAGO_INTERES_PERIODICO: for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) { $letra = $i; $letraAnterior = setNoMenorQueCero($letra - 1); $DAnterior = isset($DatosDePagados[$letraAnterior]) ? $DatosDePagados[$letraAnterior] : array(); $capital_pagado = isset($DAnterior[SYS_CAPITAL]) ? $DAnterior[SYS_CAPITAL] : 0; $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado; $DPago = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array(); $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0; //datos del pago anterior $DLetraAnterior = isset($arrPagos[$letraAnterior]) ? $arrPagos[$letraAnterior] : array(); $DLetra = isset($arrPagos[$letra]) ? $arrPagos[$letra] : array(); $FechaAnterior = isset($DLetraAnterior[SYS_FECHA]) ? $DLetraAnterior[SYS_FECHA] : $xCred->getFechaDeMinistracion(); $FechaActual = isset($DLetra[SYS_FECHA]) ? $DLetra[SYS_FECHA] : false; $DIAS_TRANSCURRIDOS = $xF->setRestarFechas($FechaActual, $FechaAnterior); //INTERES NORMAL $interes_normal = $SALDO_DE_PLAN * $DIAS_TRANSCURRIDOS * $TASA_NORMAL / $DIVISOR_DE_INTS; $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado); $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal; if ($capital_pagado > 0) { $msg .= "WARN\t{$letra}\tCapital en pago {$letraAnterior} de {$capital_pagado} \r\n"; } if ($letra == $PAGOS_AUTORIZADOS) { if ($SALDO_DE_PLAN > 0) { $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN; $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n"; } } $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado}, Dias {$DIAS_TRANSCURRIDOS},Fecha : Actual {$FechaActual} Anterior {$FechaAnterior}\r\n"; } break; case CREDITO_TIPO_PAGO_INTERES_COMERCIAL: for ($i = 1; $i <= $PAGOS_AUTORIZADOS; $i++) { $letra = $i; $letraAnterior = setNoMenorQueCero($letra - 1); $DAnterior = isset($DatosDePagados[$letraAnterior]) ? $DatosDePagados[$letraAnterior] : array(); $capital_pagado = isset($DAnterior[SYS_CAPITAL]) ? $DAnterior[SYS_CAPITAL] : 0; $SALDO_DE_PLAN = $SALDO_DE_PLAN - $capital_pagado; $DPago = isset($DatosDePagados[$letra]) ? $DatosDePagados[$letra] : array(); $interes_pagado = isset($DPago[SYS_INTERES_NORMAL]) ? $DPago[SYS_INTERES_NORMAL] : 0; //INTERES NORMAL $interes_normal = $SALDO_DE_PLAN * $PERIOCIDAD_DE_PAGO * $TASA_NORMAL / $DIVISOR_DE_INTS; $interes_normal = setNoMenorQueCero($interes_normal - $interes_pagado); $arrPagos[$letra][SYS_INTERES_NORMAL] = $interes_normal; if ($capital_pagado > 0) { $msg .= "WARN\t{$letra}\tCapital en pago {$letraAnterior} de {$capital_pagado} \r\n"; } if ($letra == $PAGOS_AUTORIZADOS) { if ($SALDO_DE_PLAN > 0) { $arrPagos[$letra][SYS_CAPITAL] = $SALDO_DE_PLAN; $msg .= "WARN\t{$letra}\tCapital a ultimo pago {$SALDO_DE_PLAN} \r\n"; } } $msg .= "OK\t{$letra}\tInteres Normal en {$interes_normal}, Pagado {$interes_pagado} \r\n"; } break; } $NumeroPlan = $this->mNumeroDePlan; //$this->setEliminar(); //eliminar plan de pagos foreach ($arrPagos as $periodo) { } $this->mMessages .= $msg; return $msg; }
//monto_parcialidad $arrUCredito["saldo_actual"] if ($xCred->getPagosAutorizados() <= $nueva_parcialidad) { if ($nuevo_saldo > TOLERANCIA_SALDOS) { $msg .= "WARN\tLa parcialidad no se Actualiza, el saldo queda a {$nuevo_saldo} de la Parcialidad {$nueva_parcialidad}\r\n"; $actualizar_parcialidad = false; } } if ($nueva_parcialidad < $xCred->getPeriodoActual()) { $msg .= "WARN\tLa Parcialidad {$nueva_parcialidad} no se mueve por ser menor al actual " . $xCred->getSaldoActual() . "\r\n"; $actualizar_parcialidad = false; } if ($actualizar_parcialidad == true) { $arrUCredito["ultimo_periodo_afectado"] = $nueva_parcialidad; } $arrUCredito["interes_normal_pagado"] = $xCred->getInteresNormalPagado() + $baseM140; $arrUCredito["interes_moratorio_pagado"] = $xCred->getInteresMoratorioPagado() + $baseM141; $xCred->setUpdate($arrUCredito); //---------------------------- Agrega Movimientos extras --------------------------------- if ($interesanticipado != 0) { $tds .= "<tr>\n <th></th>\n <td>Compensacion Intereses Cobrado por Ant</td>\n <td class='mny'>" . getFMoney($interesanticipado) . "</td>\n </tr>"; $SQL_ICA = "UPDATE operaciones_mvtos SET estatus_mvto=60, docto_neutralizador={$recibo_pago} WHERE tipo_operacion=351 AND socio_afectado={$socio} AND estatus_mvto=30"; my_query($SQL_ICA); //setPolizaProforma($recibo_pago, 352, $interesanticipado, $socio, $solicitud, TM_CARGO); } //FIXME: Verificar validez if ($interescorriente != 0) { $tds .= "<tr><th></th>\n <td>Recalculo de Interes Corriente</td>\n <td class='mny'>" . getFMoney($interescorriente) . "</td></tr>"; //setPolizaProforma($recibo_pago, 436, $interescorriente, $socio, $solicitud, TM_ABONO); } if ($interesmoroso != 0) { $tds .= "<tr><th></th>\n <td>Recalculo de Interes Moroso</td>\n <td class='mny'>" . getFMoney($interesmoroso) . "</td></tr>";