Exemplo n.º 1
0
 public function createTercerosOp(Gyuser_Model_Operations $obj, $chequesList = null)
 {
     try {
         //1. create operation
         $data = array('type' => 2, 'client_id' => $obj->getClient_id(), 'date' => $obj->getDate(), 'amount' => $obj->getAmount(), 'state_order_id' => 2, 'tasa_porcentual' => $obj->getTasa_porcentual(), 'date_added' => date('Y-m-d H:i:s'));
         $opId = $this->getDbTable()->insert($data);
         if (!$opId) {
             throw Exception("Hubo un error al crear la operación de cheques de terceros.");
         }
         //2. insert checks
         $chequesMapper = new Gyuser_Model_ChequesDataMapper();
         $chequesMapper->addChequesTerceros($opId, $chequesList);
         //3. set client to active
         $clientMapper = new Gyuser_Model_UserDataMapper();
         $clientObj = new Gyuser_Model_User();
         $clientObj->setId($obj->getClient_id());
         $clientObj->setClient_type(3);
         //active
         $clientMapper->UpdateUserType($clientObj);
         return $opId;
         //**********************************************************************
         /*
         $cheques = new Gyuser_Model_Cheques();
         $cheques->setOperation_id($obj->getId());
         $cheques->setCheques_list($chequesList);
         
         $mapper = new Gyuser_Model_OperationsDataMapper();
         $arc_hrs = $mapper->GetAcreditacionHrsByOperationId($obj);
         
         
         $result = $chequesMapper->SaveCheques($cheques);                    
         $iMapper = new Gyuser_Model_InterestsDataMapper();
         $interests = new Gyuser_Model_Interests();                    
         $interests = $iMapper->getInterestRate($obj->getInterests_id());
         
         $data = array(
             'state_order_id' => $obj->getState(),
             'amount' => $obj->getAmount(),                        
             'plan_id' => $obj->getPlan_id(),
             'interests_id' => $obj->getInterests_id(),
             'tasa_porcentual' => $interests->getRate()
         );
         */
         /*    
                     $id = (int) $obj->getId();
                     if (!$id) {
            unset($data['id']);
         
                     } else {
            $id = $this->getDbTable()->update($data, array('id = ?' => $id));
            return $id;
                     }
         * 
         */
     } catch (Exception $e) {
     }
 }
Exemplo n.º 2
0
 public function operationsformajaxAction()
 {
     try {
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender();
         $request = $this->getRequest();
         if ($this->getRequest()->isPost()) {
             $mapper = new Gyuser_Model_OperationsDataMapper();
             $Obj = new Gyuser_Model_Operations();
             $Obj->setClient_id($request->client_id);
             date_default_timezone_set('Europe/Vienna');
             list($Day, $Month, $Year) = explode('/', $request->date);
             $stampeddate = mktime(12, 0, 0, $Month, $Day, $Year);
             $realDate = date("Y-m-d", $stampeddate);
             $Obj->setDate($realDate);
             $Obj->setAmount($request->amount);
             $Obj->setState($request->state);
             $Obj->setObservations($request->observations);
             $Obj->setCave_id($request->cave);
             $Obj->setBank_account_id($request->bank_account_id);
             if ($request->id) {
                 $Obj->setId($request->id);
             }
             $id = $mapper->save($Obj);
             if ($id) {
                 //set client type to active
                 $clientMapper = new Gyuser_Model_UserDataMapper();
                 $clientObj = new Gyuser_Model_User();
                 $clientObj->setId($request->client_id);
                 $clientObj->setClient_type(3);
                 //active
                 $clientMapper->UpdateUserType($clientObj);
                 echo $id;
             } else {
                 echo "f";
             }
         }
     } catch (Exception $e) {
         echo $e;
     }
 }
Exemplo n.º 3
0
 public function RejectChequeWithGastos(Gyuser_Model_Cheques $obj)
 {
     try {
         $chequeDetails = $this->FindWithOperationNames($obj);
         $amount = (int) $this->GetAmounByChequeId($obj);
         $gastos = (int) $obj->getRejected_gastos();
         $gastos_type = $obj->getRejected_type();
         $rejectedCostProv = 'null';
         if ($chequeDetails->getLiquidacion_id()) {
             //the cheque has been passed to a provider
             $provMapper = new Gyuser_Model_ProvidersDataMapper();
             $prov = $provMapper->GetProviderByIdSimple($chequeDetails->getProvider_id());
             if ($gastos_type == "Denuncia") {
                 $rejectedCostProv = $prov->getGastos_denuncia();
             } elseif ($gastos_type == "Sin Fondos") {
                 $rejectedCostProv = $prov->getGastos_rechazo();
             }
             /*  
                             if ($chequeDetails->getCave_id()) { //the cave id property checks the provider_id field on DB, if it's not null then it's from a provider.
                $supMapper = new Gyuser_Model_SupplierOperationsDataMapper();
                $supObj = new Gyuser_Model_SupplierOperations();
                $supObj->setId($chequeDetails->getCave_id());
                $supList = $supMapper->GetCaveById($supObj); //looks for provider id (not cave)
                if ($gastos_type == "Denuncia")
                    $rejectedCostProv = $supList->getGastos_denuncia();
                elseif ($gastos_type == "Sin Fondos")
                    $rejectedCostProv = $supList->getGastos_rechazo();
                             }
                             else { //it's from lavalle
                $caveMapper = new Gyuser_Model_OtherCavesDataMapper();
                $caves = new Gyuser_Model_OtherCaves();
                $caves->setId('1'); //lavalle
                $lavalle = $caveMapper->GetCaveById($caves);
                $x = 1;
                if ($gastos_type == "Denuncia") {
                    $x = 1;
                    $rejectedCostProv = $lavalle->getGastos_denuncia();
                } elseif ($gastos_type == "Sin Fondos") {
                    $rejectedCostProv = $lavalle->getGastos_rechazo();
                }
                             }
             * 
             */
         }
         $amount = $amount + $gastos;
         $data = array('status' => 3, 'balance' => $amount, 'rejected_cost' => $gastos, 'rejected_type' => $gastos_type, 'rejected_cost_prov' => $rejectedCostProv);
         $success = $this->getDbTable()->update($data, array('id = ?' => $obj->getId()));
         if ($success) {
             $opId = $this->GetChequeOpId($obj->getId());
             //update op status to 11 = 'En Cobranza'
             $opMapper = new Gyuser_Model_OperationsDataMapper();
             $opMapper->setOperationEnCobranza($opId);
             $clientMapper = new Gyuser_Model_UserDataMapper();
             $clientId = $clientMapper->getClientByChequeId($obj->getId());
             if ($clientId) {
                 $client = new Gyuser_Model_User();
                 $client->setId($clientId);
                 $client->setClient_type(4);
                 $clientMapper->UpdateUserType($client);
             } else {
                 throw new Exception('The cheque status was updated to rejected but the client type could not be updated (to 4 = cobranza)');
             }
             //$chequeDetails = $this->FindWithOperationNames($obj);
             $mapper = new Gyuser_Model_NotificationsDataMapper();
             $obj = new Gyuser_Model_Notifications();
             $obj->setTitle('Cheque rechazado');
             $Operation_id = $chequeDetails->getOperation_id();
             $check_n = $chequeDetails->getCheck_n();
             $check_date = $chequeDetails->getDate();
             $operator_id = $request->operator_id;
             $obj->setOperator_id($Operation_id);
             $obj->setComment("El cheque {$check_n} con fecha {$check_date} op.{$Operation_id} fue rechazado por {$gastos_type}");
             $obj->setAction_date(date('Y-m-d h:i:s'));
             $result = $mapper->SaveWhenRejected($obj);
         } else {
             throw new Exception('There was an error updating the cheques table');
         }
         return $result;
     } catch (Exception $e) {
         echo $e;
     }
 }