Beispiel #1
0
 /**
  * funcion retorna registros mediante id de hader
  *
  * @param type $idHeader
  *
  * @return boolean
  */
 public function getDetailByHeader($idHeader)
 {
     $query = Detail::where('op_td_header_id', '=', $idHeader);
     $this->model = $query->get();
     if ($this->model->count() == 1) {
         $this->model = $this->model->first();
         return true;
     }
     return false;
 }
Beispiel #2
0
 public function listInsured($rp_id, $header_id, $steep)
 {
     $prodParam = ProductParameter::where('ad_retailer_product_id', decode($rp_id))->where('slug', 'GE')->first();
     $detail = Detail::where('op_td_header_id', decode($header_id))->get();
     $exedDetail = 0;
     if (count($detail) == $prodParam->detail) {
         $exedDetail = $prodParam->detail;
     }
     $var = ['template' => view('td.listInsured', compact('detail', 'header_id', 'rp_id', 'exedDetail', 'prodParam', 'steep'))->render()];
     return response()->json($var);
 }
 /**
  * fucion determina regla facultativo mediante el valor asegurado.
  *
  * @param type $idHeader
  */
 public function roleFacultative($rpId, $idHeader, $header)
 {
     $moneda = $this->returnTipoCambio($rpId, $header);
     $ge = ProductParameter::where('ad_retailer_product_id', $rpId)->where('slug', 'GE')->first();
     $fa = ProductParameter::where('ad_retailer_product_id', $rpId)->where('slug', 'FA')->first();
     $detail = Detail::where('op_td_header_id', $idHeader)->get();
     $totalInsured = 0;
     $facultative = [];
     $arrayFac = [];
     $keyFac = 0;
     # validacion facultativos por riesgo
     foreach ($detail as $key => $value) {
         if ($value->matter_insured == 'PR' && $value->use == 'IP') {
             if ($value->insured_value >= $fa->amount_min * $moneda && $value->insured_value <= $fa->amount_max * $moneda) {
                 $arrayFac['role1'][] = $value;
                 $keyFac++;
             }
         }
         $totalInsured += $value->insured_value;
     }
     # validacion facultativos generales
     if ($totalInsured > $ge->amount_max * $moneda) {
         $arrayFac['role2']['total_amount'] = $totalInsured;
         $arrayFac['role2']['amount_max'] = $ge->amount_max * $moneda;
         $arrayFac['role2']['details'] = $detail;
         $keyFac++;
     }
     $facultative['facultative'] = $keyFac;
     $facultative['roles'] = $arrayFac;
     $facultative['parameter']['FA'] = $fa;
     $facultative['parameter']['GE'] = $ge;
     return $facultative;
 }