Esempio n. 1
0
 public static function synchronizeInterestCurrencyData($brand)
 {
     $db = new CurrencyInterest();
     $brand_model = new Branch();
     $id_branch = $brand_model->getIdBranchByName(ucfirst($brand));
     $downloaded = self::getDepProductsList($brand, array("REGEXP_LIKE(\"SYMBOL\", '^LTS(O|F)(M|D)1\\.[A-Z]{1,5}\$')", "NOT REGEXP_LIKE(\"SYMBOL\", '^LTS(O|F)(M|D)1\\.PLN\$')"), false);
     $insert = array();
     $current = $db->getDataByBranchArray($id_branch);
     foreach ($current as $currency => $dd) {
         foreach ($dd as $client_type => $json) {
             if (isset($downloaded[$client_type . $currency])) {
                 $json_new = $downloaded[$client_type . $currency]['json_data'];
             } else {
                 //   $json_new = Zend_Json_Encoder::encode(Logic_Inputdata_Form_CurrencyInterest::get0FillInterest());
                 $json_new = Logic_Inputdata_Form_CurrencyInterest::get0FillInterest();
             }
             foreach ($json_new['data'] as $period => $d) {
                 foreach ($d as $number => $value) {
                     if ($value['interest'] != $json['json_data']['data'][$period][$number]['interest']) {
                         $insert["interest_" . $id_branch . "_" . $currency . "_" . $client_type . "_" . $period . "_" . $number] = str_replace('.', ',', $value['interest']);
                     }
                 }
             }
         }
     }
     $session = new Zend_Session_Namespace('interest_synchro');
     if (empty($insert)) {
         $session->data = 'empty';
     } else {
         $session->data = $insert;
     }
 }
Esempio n. 2
0
 public function init()
 {
     $value = $this->getValue();
     if ($this->_riseValue === null) {
         if ($value == 0) {
             $baseInterestModel = new CurrencyInterest();
             $data = $baseInterestModel->getDataByInput($this->brandId, $this->currency, $this->customerType);
             $m = $this->daysToM($this->depositDays);
             foreach ($data as $v) {
                 $d = Zend_Json_Decoder::decode($v['json_data']);
                 //$tendency = round((float) ($d['tendency'] / 10), 2);
                 if ($d['data'][$m][3]['low_currency_bracket'] * 1000 <= $this->depositAmount) {
                     //  $this->_riseValue = $d['data'][$m][3]['interest'];
                     $hight = 3;
                     break;
                 } elseif ($d['data'][$m][2]['low_currency_bracket'] * 1000 <= $this->depositAmount) {
                     //  $this->_riseValue = $d['data'][$m][2]['interest'];
                     $hight = 2;
                     break;
                 } elseif ($d['data'][$m][1]['low_currency_bracket'] * 1000 <= $this->depositAmount) {
                     //  $this->_riseValue = $d['data'][$m][1]['interest'];
                     $hight = 1;
                     break;
                 } elseif ($d['data'][$m][0]['low_currency_bracket'] * 1000 <= $this->depositAmount) {
                     // $this->_riseValue = $d['data'][$m][0]['interest'];
                     $hight = 0;
                     break;
                 } else {
                     throw new Exception('Unrecodnizable deposit amount', '45');
                 }
             }
             if ($this->depositDays <= 90) {
                 $this->_riseValue = $this->linearInterpolation(0, 90, 0, $d['data']['3M'][$hight]['interest'], $this->depositDays);
             } elseif ($this->depositDays <= 180) {
                 $this->_riseValue = $this->linearInterpolation(90, 180, $d['data']['3M'][$hight]['interest'], $d['data']['6M'][$hight]['interest'], $this->depositDays);
             } elseif ($this->depositDays <= 365) {
                 $this->_riseValue = $this->linearInterpolation(180, 365, $d['data']['6M'][$hight]['interest'], $d['data']['12M'][$hight]['interest'], $this->depositDays);
             } else {
                 $this->_riseValue = $d['data'][$m][$hight]['interest'];
             }
         }
         $queryModel = new NegotiationQuery();
         $queryRow = $queryModel->fetchRow(array('ghost = ?' => 'f', 'for_pln = ?' => 'f'), 'id DESC');
         $tendencyModel = new NegotiationTendency();
         $tendencyRow = $tendencyModel->fetchRow(array('customer_type = ?' => $this->customerType, 'for_pln = ?' => 'f', 'ghost = ?' => 'f'), 'created_at DESC');
         $tendency = round((double) ($tendencyRow->tendency / 100), 4);
         switch ($this->counterOfferNo) {
             case 0:
                 $value += $this->_riseValue;
                 $this->setValue($value);
                 return;
             case 1:
                 $column = 'additional1';
                 break;
             case 2:
                 $column = 'additional2';
                 break;
             case 3:
                 $column = 'additional3';
                 break;
             case -1:
                 $value += $this->_riseValue;
                 $this->setValue($value);
                 return;
         }
         $x = (double) ($queryRow->{$column} / 100);
         $this->_riseValue += round($tendency * $x, 4);
     }
     $value += $this->_riseValue;
     $this->setValue($value);
 }