コード例 #1
0
 public function saveDetails($id, Gyuser_Model_Providers $provData)
 {
     $table = $this->getDbTable();
     $select = $table->select();
     $select->setIntegrityCheck(false);
     $select->from(array('cqu' => 'cheques'), array('id', 'date', 'amount', 'bank_account_id'));
     $select->joinLeft(array('bnk' => 'bank_accounts'), 'cqu.bank_account_id = bnk.id', array('location_capital as loc'));
     $select->where('cqu.id = ?', $id);
     $row = $table->fetchRow($select);
     $cDetails = $this->calculateCheckDetails((double) $row['amount'], $row['date'], (int) $row['loc'], $provData);
     $cheque = new Gyuser_Model_Cheques();
     $cheque->setTerceros_tasa_anual($provData->getTasa_anual());
     $cheque->setTerceros_ac_date($cDetails['acreditationDate']);
     $cheque->setTerceros_today_value($cDetails['todayValue']);
     $cheque->setTerceros_days($cDetails['days']);
     $cheque->setTerceros_location($cDetails['locacionCapital']);
     $cheque->setTerceros_ac_hours($cDetails['acreditationHrs']);
     $cheque->setTerceros_imp_al_cheque($cDetails['impuestoAlCheque']);
     if ($cDetails['locacionCapital'] == 1) {
         //capital
         $cheque->setTerceros_gastos_general($cDetails['gastos']);
     } elseif ($cDetails['locacionCapital'] == 2) {
         //interior
         $cheque->setTerceros_gastos_interior($cDetails['gastos']);
     }
     $cheque->setTerceros_descuento($cDetails['daysDiscountFee']);
     // ($chequeAmt * $tasaDiaria / 100) * $dateDiff;
     $data = array('terceros_tasa_anual' => $cheque->getTerceros_tasa_anual(), 'terceros_ac_date' => $cheque->getTerceros_ac_date(), 'terceros_today_value' => $cheque->getTerceros_today_value(), 'terceros_days' => $cheque->getTerceros_days(), 'terceros_location' => $cheque->getTerceros_location(), 'terceros_ac_hours' => $cheque->getTerceros_ac_hours(), 'terceros_imp_al_cheque' => $cheque->getTerceros_imp_al_cheque(), 'terceros_gastos_general' => $cheque->getTerceros_gastos_general(), 'terceros_gastos_interior' => $cheque->getTerceros_gastos_interior(), 'terceros_descuento' => $cheque->getTerceros_descuento());
     $success = $this->getDbTable()->update($data, array('id = ?' => $id));
     if (!$success) {
         throw new Exception('Cheque de tercero update failed.');
     }
     $data['amount'] = (double) $row['amount'];
     return $data;
 }