public function storeSubProduct(HeaderSpCreateFormRequest $request, $rp_id, $header_id, $sp_id) { $beneficiaries = $request->get('beneficiaries'); $participation = 0; foreach ($beneficiaries as $beneficiary) { $participation += $beneficiary['participation']; } if ($participation == 100) { $success_header = ['success_header' => 'El Sub-Producto fue asociado correctamente']; if ($this->headerDeRepository->getHeaderById(decode($header_id)) && $this->retailerProductRepository->getRetailerProductById(decode($sp_id))) { $headerDe = $this->headerDeRepository->getModel(); $detailDe = $headerDe->details()->where('id', decode($request->get('detail_id')))->first(); $retailerProduct = $this->retailerProductRepository->getModel(); $request['detail'] = $detailDe; $request['policies'] = $this->policyRepository->getPolicyByProduct(decode($sp_id)); $request['plans'] = $this->planRepository->getPlansByProduct(decode($sp_id)); if ($this->repository->storeSubProduct($request, $retailerProduct) && $this->accountRepository->storeAccount($request)) { if ($this->repository->destroyClientCacheSP(decode($header_id), decode($request->get('detail_id')))) { return redirect()->route('de.vi.sp.create', ['rp_id' => $rp_id, 'header_id' => $header_id, 'sp_id' => $sp_id])->with($success_header); } else { return redirect()->route('de.issuance', ['rp_id' => $rp_id, 'header_id' => $header_id])->with($success_header); } } } } else { return redirect()->back()->with(['error_participation' => 'La suma de porcentajes de Beneficiarios del Titular debe ser del 100%'])->withInput(); } return redirect()->back()->with(['error_header' => 'El Sub-Producto no puede ser asociado al Titular'])->withInput()->withErrors($this->repository->getErrors()); }
/** * @param string $rp_id * @param string $de_id * @param string $header_id * * @return mixed */ public function coverageEdit($rp_id, $de_id, $header_id) { if (Cache::has(decode($header_id)) && $this->repository->getHeaderById(decode($header_id))) { $header = $this->repository->getModel(); $data = $this->getData($rp_id); $data['policies'] = $this->policyRepository->getPolicyByCurrency(decode($rp_id), $header->currency); $data['payment_methods'] = $this->retailerProductRepository->getPaymentMethodsByProductById(decode($rp_id)); return view('td.coverage.edit', compact('rp_id', 'de_id', 'header_id', 'header', 'data')); } return redirect()->back()->with(['error_header' => 'La cobertura no puede ser inicializada . ']); }
public function policyByProduct($rp_id) { return $this->repository->getPolicyByProduct($rp_id); }
/** * Returns data for create Header * * @param string $rp_id * * @return array */ protected function getData($rp_id) { return ['coverages' => $this->retailerProductRepository->getCoverageByProduct($rp_id), 'currencies' => $this->dataRepository->getCurrency(), 'term_types' => $this->dataRepository->getTermType(), 'credit_products' => $this->retailerProductRepository->getCreditProductByProduct($rp_id), 'movement_types' => $this->dataRepository->getMovementType(), 'policies' => $this->policyRepository->gerPolicyForIssuance($rp_id)]; }