public function deleteliquidacionesAction() { try { $request = $this->getRequest(); $liquidaciones_id = (int) $request->liquidaciones_id; if ($liquidaciones_id) { $lMapper = new Gyuser_Model_LiquidacionesDataMapper(); $lObj = new Gyuser_Model_Liquidaciones(); $lObj->setId($liquidaciones_id); $lList = $lMapper->GetLiquidacionesById($lObj); $provider_id = $lList['provider_id']; $pMapper = new Gyuser_Model_ProvidersDataMapper(); $prov = new Gyuser_Model_Providers(); $prov->setId($provider_id); $prov->setBalance(floatval($lList['previous_account_balance'])); $pMapper->UpdateBalanceByReject($prov); $cMapper = new Gyuser_Model_ChequesDataMapper(); $chequesList = $cMapper->UpdateLiquidacionDeleted($liquidaciones_id); $oMapper = new Gyuser_Model_OperationsDataMapper(); $opertationsList = $oMapper->UpdateLiquidacionDeleted($liquidaciones_id); $cList = $lMapper->delete($lObj); if ($cList && $chequesList && $opertationsList) { $result = '1'; } else { $result = '0'; } $this->_helper->redirector('providers', 'liquidaciones', 'gyuser', array('provider_id' => $request->provider_id)); } } catch (Exception $e) { echo $e; } }
public function providereditajaxAction() { try { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $request = $this->getRequest(); if ($this->getRequest()->isPost()) { $mapper = new Gyuser_Model_ProvidersDataMapper(); $Obj = new Gyuser_Model_Providers(); if ($request->id) { $Obj->setId($request->id); } $Obj->setName($request->name); $Obj->setEmail($request->email); $Obj->setTasa_anual($request->tasa_anual); $Obj->setImpuesto_al_cheque($request->impuesto_al_cheque); $Obj->setGastos_interior($request->gastos_interior); $Obj->setGastos_general($request->gastos_general); $Obj->setGastos_denuncia($request->gastos_denuncia); $Obj->setGastos_rechazo($request->gastos_rechazo); $Obj->setAcreditacion_capital($request->acreditacion_capital); $Obj->setAcreditacion_interior($request->acreditacion_interior); $Obj->setGastos_cheque_menor_a_1($request->gastos_cheque_menor_a_1); $Obj->setGastos_cheque_a_1($request->gastos_cheque_a_1); $Obj->setGastos_cheque_menor_a_2($request->gastos_cheque_menor_a_2); $Obj->setGastos_cheque_a_2($request->gastos_cheque_a_2); $id = $mapper->update($Obj); if ($id) { echo $id; } else { echo "f"; } } } catch (Exception $e) { echo $e; } }
public function getProviders() { $table = $this->getDbTable(); $select = $table->select(); $select->setIntegrityCheck(false); $select->from('providers', array('id', 'name', 'email', 'balance', 'tasa_anual', 'impuesto_al_cheque', 'gastos_general', 'gastos_interior', 'gastos_denuncia', 'gastos_rechazo', 'acreditacion_capital', 'acreditacion_interior', 'gastos_menor_a_monto_1', 'gastos_menor_a_1', 'gastos_menor_a_monto_2', 'gastos_menor_a_2')); $select->joinLeft(array('cqu' => 'cheques'), 'cqu.provider_id = providers.id and cqu.status = 3 and cqu.rejected_liquidacion_id IS NULL', array('sum(amount) as rej_amount', 'sum(rejected_cost) as rej_cost')); //$select->where('cqu.status = ?', 3); //$select->where('cqu.rejected_liquidacion_id IS NULL'); $select->where('providers.status = ?', true); $select->group('providers.id'); $select->order('id ASC'); $resultset = $table->fetchAll($select); $entires = array(); foreach ($resultset as $row) { //$entry = new Gyuser_Model_SupplierOperations(); $entry = new Gyuser_Model_Providers(); $entry->setId($row->id); $entry->setName($row->name); $entry->setEmail($row->email); $entry->setBalance($row->balance); $entry->setTasa_anual($row->tasa_anual); $entry->setImpuesto_al_cheque($row->impuesto_al_cheque); $entry->setGastos_general($row->gastos_general); $entry->setGastos_interior($row->gastos_interior); $entry->setGastos_denuncia($row->gastos_denuncia); $entry->setGastos_rechazo($row->gastos_rechazo); $entry->setAcreditacion_capital($row->acreditacion_capital); $entry->setAcreditacion_interior($row->acreditacion_interior); $entry->setGastos_cheque_menor_a_1($row->gastos_menor_a_monto_1); $entry->setGastos_cheque_a_1($row->gastos_menor_a_1); $entry->setGastos_cheque_menor_a_2($row->gastos_menor_a_monto_2); $entry->setGastos_cheque_a_2($row->gastos_menor_a_2); $entry->setRej_check_amount(floatval($row->rej_amount) + floatval($row->rej_cost)); $cMapper = new Gyuser_Model_ChequesDataMapper(); $cObj = new Gyuser_Model_Cheques(); $cObj->setStatus(4); $cObj->setProvider_id($row->id); $cAmount = $cMapper->GetTotalAmountByStats($cObj); $entry->setPassed_amount($cAmount); $entires[] = $entry; } return $entires; }
public function calculateCheckDetails($chequeAmt, $chequeDate, $chequeLocation, Gyuser_Model_Providers $provData, $liqDate = null) { $tasaDiaria = 0; $gastosOtros = 0; $date_diff = ''; if (is_null($liqDate)) { $liqDate = date("d/m/Y"); } //today /*if(!$liqDataId) { $provMapper = new Gyuser_Model_ProvidersDataMapper(); $provDetails = $provMapper->GetProviderById($provId); if(is_null($liqDate)) $liqDate = date("d/m/Y"); $liqData = array( 'liqDate' => $liqDate, //global var with server current date or liquidacion date (if changed from current date); 'impuestoAlCheque' => $provDetails->getImpuesto_al_cheque(), 'tasaAnual' => $provDetails->getTasa_anual(), 'acCapital' => $provDetails->getAcreditacion_capital(), 'acInterior' => $provDetails->getAcreditacion_interior(), 'gastosGeneral' => $provDetails->getGastos_general(), 'gastosInterior' => $provDetails->getGastos_interior(), 'gastosChequeMenorA1' => $provDetails->getGastos_cheque_menor_a_1(), 'gastosFeeChequeMenorA1' => $provDetails->getGastos_cheque_a_1(), 'gastosChequeMenorA2' => $provDetails->getGastos_cheque_menor_a_2(), 'gastosFeeChequeMenorA2' => $provDetails->getGastos_cheque_a_2(), ); } else { $liqMapper = new Gyuser_Model_LiquidacionesDataMapper(); $liqData = $liqMapper->getLiqData($liqDataId); } */ if ($chequeLocation == 1) { //cheque is from capital $acredHs = $provData->getAcreditacion_capital(); $gastosFee = $provData->getGastos_general(); } elseif ($chequeLocation == 2) { //cheque is from interior $acredHs = $provData->getAcreditacion_interior(); if ($provData->getGastos_interior()) { $gastosFee = $provData->getGastos_interior(); } else { $gastosFee = $provData->getGastos_general(); } } //theres's a fee for small cheques if ($provData->getGastos_cheque_menor_a_1()) { //make sure cheque menor a 1 is smaller than 2 if ($provData->getGastos_cheque_menor_a_1() > $provData->getGastos_cheque_menor_a_2()) { $temp1 = $provData->getGastos_cheque_menor_a_1(); $temp2 = $provData->getGastos_cheque_a_1(); $provData->setGastos_cheque_menor_a_1($provData->getGastos_cheque_menor_a_2()); $provData->setGastos_cheque_a_1($provData->getGastos_cheque_a_2()); $provData->setGastos_cheque_a_2($temp1); $provData->setGastos_cheque_menor_a_2($temp2); } if ($chequeAmt < $provData->getGastos_cheque_menor_a_1()) { $gastosOtros = $provData->getGastos_cheque_a_1(); } elseif ($chequeAmt < $provData->getGastos_cheque_menor_a_2()) { $gastosOtros = $provData->getGastos_cheque_a_2(); } } $tasaDiaria = $provData->getTasa_anual() / 360; $impuestoAlCheque = $chequeAmt * $provData->getImpuesto_al_cheque() / 100; $gastos = $chequeAmt * $gastosFee / 100; //gralDiscounts = (chequeAmt * (impuesto_al_cheque + gastos)) / 100; //impuesto al cheuqe and gastos are percentages. $acredDate = $this->getAcredDate($chequeDate, $acredHs); $dateDiff = $this->daysBetween($liqDate, $acredDate); $descuento = $chequeAmt * $tasaDiaria / 100 * $dateDiff; //$descuento = number_format($descuento,2,'.',''); $todayValue = $chequeAmt - $impuestoAlCheque - $descuento - $gastos - $gastosOtros; //$todayValue = number_format($todayValue,2,'.',''); $chequeDetails = array('days' => $dateDiff, 'todayValue' => $todayValue, 'impuestoAlCheque' => $impuestoAlCheque, 'gastos' => $gastos, 'gastosOtros' => $gastosOtros, 'daysDiscountFee' => $descuento, 'acreditationHrs' => $acredHs, 'acreditationDate' => $acredDate, 'locacionCapital' => $chequeLocation); return $chequeDetails; }
public function getProvData($liqId) { $table = $this->getDbTable(); $select = $table->select(); $select->setIntegrityCheck(false); $select->from($table, array('id', 'provider_id', 'date', 'impuesto_al_cheque', 'tasa_anual', 'acreditacion_capital', 'acreditacion_interior', 'gastos_general', 'gastos_interior', 'gastos_menor_a_monto_1', 'gastos_menor_a_1', 'gastos_menor_a_monto_2', 'gastos_menor_a_2', 'committed')); $select->join(array('prov' => 'providers'), 'liquidaciones.provider_id = prov.id', array('name as provider_name', 'email')); $select->where('liquidaciones.id = ?', $liqId); $row = $table->fetchRow($select); if ($row) { $prov = new Gyuser_Model_Providers(); $prov->setId($row->id); $prov->setName($row->provider_name); $prov->setEmail($row->email); $prov->setImpuesto_al_cheque($row->impuesto_al_cheque); $prov->setTasa_anual($row->tasa_anual); $prov->setAcreditacion_capital($row->acreditacion_capital); $prov->setAcreditacion_interior($row->acreditacion_interior); $prov->setGastos_general($row->gastos_general); $prov->setGastos_interior($row->gastos_interior); $prov->setGastos_cheque_menor_a_1($row->gastos_menor_a_monto_1); $prov->setGastos_cheque_a_1($row->gastos_menor_a_1); $prov->setGastos_cheque_menor_a_2($row->gastos_menor_a_monto_2); $prov->setGastos_cheque_a_2($row->gastos_menor_a_2); } return $prov; }
public function OpTercerosStateChange($opId, $newStateId, $tasaAnual = null, $chequesListJson = null) { $success = 0; $obj = new Gyuser_Model_Operations(); $obj->setId($opId); $opResult = $this->GetStateByOperationId($obj); $currentStateId = (int) $opResult['stateid']; if ($currentStateId < $newStateId) { switch ($newStateId) { case 2: $data = array('state_order_id' => $obj->getState(), 'cave_id' => $obj->getCave_id()); break; case 3: case 4: $data = array('state_order_id' => $obj->getState(), 'report' => $obj->getReport()); break; case 5: //cerrada $chequesMapper = new Gyuser_Model_ChequesDataMapper(); $informesCompletos = $chequesMapper->checkInformesCompletos($opId); if ($informesCompletos) { $data = array('state_order_id' => $newStateId); } break; case 6: //op. en camino $opAmount = 0; $opTodayVal = 0; $adminMapper = new Gyuser_Model_AdminDataMapper(); $admin = $adminMapper->getAdminSettings(); $prov = new Gyuser_Model_Providers(); $prov->setAcreditacion_capital($admin->getTiempo_ac_capital()); $prov->setAcreditacion_interior($admin->getTiempo_ac_interior()); $prov->setGastos_general($admin->getGastos_general()); $prov->setGastos_interior($admin->getGastos_interior()); $prov->setImpuesto_al_cheque($admin->getImpuesto_al_cheque()); $prov->setTasa_anual($tasaAnual); $chequesMapper = new Gyuser_Model_ChequesDataMapper(); $cheque = new Gyuser_Model_Cheques(); $cheques = $chequesMapper->GetChequesByOpId($opId); //gets only cheques with status 7 (aprobados) foreach ($cheques as $cheque) { $cDetails = $chequesMapper->saveDetails($cheque->getId(), $prov); $opAmount += $cDetails['amount']; $opTodayVal += $cDetails['terceros_today_value']; } $data = array('amount' => $opAmount, 'amount_today' => $opTodayVal, 'ac_date' => date('Y-m-d'), 'tasa_porcentual' => $tasaAnual, 'state_order_id' => $newStateId); break; case 9: //consolidated / cheques en cartera $chequesList = json_decode($chequesListJson); $chequesMapper = new Gyuser_Model_ChequesDataMapper(); $chequesTotals = $chequesMapper->consolidateCheques($chequesList); $data = array('amount' => $chequesTotals['amount'], 'amount_today' => $chequesTotals['todayValue'], 'state_order_id' => $newStateId); break; case 99: $chequesMapper = new Gyuser_Model_ChequesDataMapper(); $cheques = new Gyuser_Model_Cheques(); $cheques->setOperation_id($obj->getId()); $result = $chequesMapper->deleteByOperationId($cheques); $data = array('state_order_id' => $obj->getState()); break; default: $data = array('state_order_id' => $obj->getState()); break; } if ($data) { $id = (int) $obj->getId(); $id = $this->getDbTable()->update($data, array('id = ?' => $id)); } $success = 1; } elseif ($currentStateId >= $newStateId) { //new state is smaller or equal to current state $success = 2; } //2 = the state has already been changed. return $success; }