function setAcumularIntereses($Forzar = false, $credito = false) { $msg = ""; $ql = new MQL(); if ($Forzar == true) { $msg .= "======\t\tActualizacion FORZADA\r\n"; } $ByWCredito = $credito == false ? "" : " WHERE numero_solicitud={$credito} "; $sqlACero = "UPDATE creditos_solicitud\n\t\t\t\t\tSET sdo_int_ant=0, interes_normal_devengado=0, interes_normal_pagado=0,\n\t\t\t\t\tinteres_moratorio_devengado=0, interes_moratorio_pagado=0 {$ByWCredito}"; my_query($sqlACero); $xB = new cBases(0); $xB->setClave(2200); $aMorDev = $xB->getBaseMvtosInArray(); $xB->setClave(2210); $aMorPag = $xB->getBaseMvtosInArray(); $xB->setClave(2100); $aNorDev = $xB->getBaseMvtosInArray(); $xB->setClave(2110); $aNorPag = $xB->getBaseMvtosInArray(); $conteo = 1; $sql = "SELECT * FROM creditos_solicitud {$ByWCredito} ORDER BY saldo_actual, fecha_ministracion"; $rs = $ql->getDataRecord($sql); //getRecordset($sql); foreach ($rs as $rw) { $socio = $rw["numero_socio"]; $solicitud = $rw["numero_solicitud"]; $saldo = $rw["saldo_actual"]; $IntMorDev = isset($aMorDev["{$socio}@{$solicitud}"]) ? round(setNoMenorQueCero($aMorDev["{$socio}@{$solicitud}"]), 2) : 0; $IntMorPag = isset($aMorPag["{$socio}@{$solicitud}"]) ? round(setNoMenorQueCero($aMorPag["{$socio}@{$solicitud}"]), 2) : 0; $IntNorDev = isset($aNorDev["{$socio}@{$solicitud}"]) ? round(setNoMenorQueCero($aNorDev["{$socio}@{$solicitud}"]), 2) : 0; $IntNorPag = isset($aNorPag["{$socio}@{$solicitud}"]) ? round(setNoMenorQueCero($aNorPag["{$socio}@{$solicitud}"]), 2) : 0; $sdoNorm = round($IntNorDev - $IntNorPag, 2); $sdoMor = round($IntMorDev - $IntMorPag, 2); if ($saldo <= TOLERANCIA_SALDOS and $Forzar == false) { $msg .= "{$conteo}\t{$socio}\t{$solicitud}\tNOTA_INTERES\tCredito Pagado, Saldo {$saldo}, Intereses a Cero\r\n "; $IntMorDev = 0; $IntMorPag = 0; $IntNorDev = 0; $IntNorPag = 0; $sdoNorm = 0; $sdoMor = 0; } $sql = "UPDATE creditos_solicitud\n\t\t\t\t\t\t\t\tSET sdo_int_ant=0, interes_normal_devengado={$IntNorDev}, interes_normal_pagado={$IntNorPag},\n\t\t\t\t\t\t\t\tinteres_moratorio_devengado={$IntMorDev}, interes_moratorio_pagado={$IntMorPag}\n\t\t\t\t\t\t\t\tWHERE numero_solicitud={$solicitud} AND numero_socio={$socio} "; my_query($sql); $msg .= "{$conteo}\t{$socio}\t{$solicitud}\tINT_NORMAL_C\tDevengado:\t{$IntNorDev}\tPagado:\t{$IntNorPag}\tSaldo\t{$sdoNorm}\r\n "; if ($IntMorPag != 0 and $IntMorDev != 0) { $msg .= "{$conteo}\t{$socio}\t{$solicitud}\tINT_MORATORIO\tDevengado:\t{$IntMorDev}\tPagado:\t{$IntMorPag}\tSaldo\t{$sdoMor}\r \r\n "; } $conteo++; } return $msg; }