public function update(Gyuser_Model_Providers $obj) { $data = array('id' => $obj->getId(), 'name' => $obj->getName(), 'email' => $obj->getEmail(), 'tasa_anual' => $obj->getTasa_anual(), 'impuesto_al_cheque' => $obj->getImpuesto_al_cheque(), 'gastos_general' => $obj->getGastos_general(), 'gastos_interior' => $obj->getGastos_interior(), 'gastos_denuncia' => $obj->getGastos_denuncia(), 'gastos_rechazo' => $obj->getGastos_rechazo(), 'acreditacion_capital' => $obj->getAcreditacion_capital(), 'acreditacion_interior' => $obj->getAcreditacion_interior(), 'gastos_menor_a_monto_1' => $obj->getGastos_cheque_menor_a_1() ? $obj->getGastos_cheque_menor_a_1() : null, 'gastos_menor_a_1' => $obj->getGastos_cheque_a_1() ? $obj->getGastos_cheque_a_1() : null, 'gastos_menor_a_monto_2' => $obj->getGastos_cheque_menor_a_2() ? $obj->getGastos_cheque_menor_a_2() : null, 'gastos_menor_a_2' => $obj->getGastos_cheque_a_2() ? $obj->getGastos_cheque_a_2() : null); $id = (int) $obj->getId(); if (!$id) { unset($data['id']); $id = $this->getDbTable()->insert($data); return $id; } else { $id = $this->getDbTable()->update($data, array('id = ?' => $id)); return $id; } }
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; }