public function testDocusignAllowed() { $transferInformation = new TransferInformation(); $transferCustodian = new TransferCustodian(); $transferInformation->setTransferCustodian($transferCustodian); $this->assertEquals(true, $this->condition->check($transferInformation)); }
protected function checkObject(TransferInformation $object) { if (!is_object($object->getTransferCustodian())) { return false; } return true; }
protected function checkObject(TransferInformation $object) { if (!$object->getIsIncludePolicy()) { return true; } return false; }
protected function checkObject(TransferInformation $object) { /** @var TransferCustodianQuestionAnswer $questionnaireAnswer */ foreach ($object->getQuestionnaireAnswers() as $questionnaireAnswer) { $question = $questionnaireAnswer->getQuestion(); $value = (bool) $questionnaireAnswer->getValue(); if ($value !== $question->getDocusignEligibleAnswer()) { return false; } } return true; }
public function testDocusignNotAllowed() { $transferInformation = new TransferInformation(); $questionMock1 = $this->getQuestionMock(); $questionMock1->setDocusignEligibleAnswer(true); $questionMock2 = $this->getQuestionMock(); $questionMock2->setDocusignEligibleAnswer(true); $answerMock1 = $this->getAnswerMock(); $answerMock1->setQuestion($questionMock1); $answerMock1->setValue(true); $answerMock2 = $this->getAnswerMock(); $answerMock2->setQuestion($questionMock1); $answerMock2->setValue(false); $transferInformation->addQuestionnaireAnswer($answerMock1); $transferInformation->addQuestionnaireAnswer($answerMock2); $this->assertEquals(false, $this->condition->check($transferInformation)); }
protected function checkObject(TransferInformation $object) { $account = $object->getClientAccount(); $consolidator = $account->getConsolidator(); if ($consolidator) { $primaryApplicant = $consolidator->getPrimaryApplicant(); $accountTitle = $primaryApplicant->getFirstName() . ' ' . $primaryApplicant->getMiddleName() . ' ' . $primaryApplicant->getLastName(); if ($accountTitle !== $object->getAccountTitle()) { return false; } if ($consolidator->isJointType()) { $secondaryApplicant = $consolidator->getSecondaryApplicant(); $jointAccountTitle = $secondaryApplicant->getFirstName() . ' ' . $secondaryApplicant->getMiddleName() . ' ' . $secondaryApplicant->getLastName(); if ($jointAccountTitle !== $object->getAccountJointTitle()) { return false; } } } return true; }
protected function validateStatementDocument(FormInterface $form, TransferInformation $data) { if (!$data->getStatementDocument()) { $form->get('statementDocument')->addError(new FormError('Upload a file.')); } }
public function testDocusignAllowed() { $transferInformation = new TransferInformation(); $transferInformation->setIsIncludePolicy(true); $this->assertEquals(false, $this->condition->check($transferInformation)); }
public function transferAction(Request $request) { /** @var $em EntityManager */ /** @var $repo ClientAccountRepository */ $em = $this->get('doctrine.orm.entity_manager'); $repo = $em->getRepository('WealthbotClientBundle:ClientAccount'); $adm = $this->get('wealthbot_docusign.account_docusign.manager'); $documentSignatureManager = $this->get('wealthbot_docusign.document_signature.manager'); $client = $this->getUser(); /** @var $account ClientAccount */ $account = $repo->findOneBy(array('id' => $request->get('account_id'), 'client_id' => $client->getId())); if (!$account) { $this->createNotFoundException('You have not account with id: ' . $request->get('account_id') . '.'); } $this->denyAccessForCurrentRetirementAccount($account); if (!$account->hasGroup(AccountGroup::GROUP_FINANCIAL_INSTITUTION)) { throw new AccessDeniedHttpException('Current account has not this step.'); } $accountIndex = $request->get('account_index', 1); $consolidatedAccounts = $account->getConsolidatedAccountsCollection(); $consolidatedAccounts->first(); $transferAccounts = $consolidatedAccounts->getTransferAccounts(); if ($transferAccounts->isEmpty()) { $this->createNotFoundException('You have not transfer accounts.'); } if (!$transferAccounts->containsKey($accountIndex)) { throw $this->createNotFoundException('Page not found.'); } $currentAccount = $transferAccounts->get($accountIndex); /** @var $information TransferInformation */ $information = $currentAccount->getTransferInformation(); if (!$information) { $information = new TransferInformation(); $information->setClientAccount($currentAccount); $information->setFinancialInstitution($currentAccount->getFinancialInstitution()); } $isPreSaved = $request->isXmlHttpRequest(); $form = $this->createForm(new TransferInformationFormType($adm, $isPreSaved), $information); $formHandler = new TransferInformationFormHandler($form, $request, $em, array('client' => $client)); if ($request->isMethod('post')) { if ($formHandler->process()) { /** @var TransferInformation $information */ $information = $form->getData(); $account->setStepAction(ClientAccount::STEP_ACTION_TRANSFER); $account->setIsPreSaved($isPreSaved); $isDocusignAllowed = $adm->isDocusignAllowed($information, array(new TransferInformationCustodianCondition(), new TransferInformationPolicyCondition(), new TransferInformationQuestionnaireCondition(), new TransferInformationConsolidatorCondition())); $adm->setIsUsedDocusign($account, $isDocusignAllowed); if (!$documentSignatureManager->isDocumentSignatureForObjectExist($information)) { $documentSignatureManager->createSignature($information); } $redirectUrl = $this->getRedirectUrl($account, ClientAccount::STEP_ACTION_TRANSFER); if ($isPreSaved) { return $this->getJsonResponse(array('status' => 'success', 'redirect_url' => $redirectUrl)); } // If account has next consolidated transfer account than redirect to it // else redirect to another step if ($transferAccounts->containsNextKey($accountIndex)) { return $this->redirect($this->generateUrl($this->getRoutePrefix() . 'transfer_transfer_account', array('account_id' => $account->getId(), 'account_index' => $accountIndex + 1))); } else { return $this->redirect($redirectUrl); } } else { if ($isPreSaved) { return $this->getJsonResponse(array('status' => 'error', 'form' => $this->renderView($this->getTemplate('_transfer_form.html.twig'), array('account' => $account, 'current_account' => $currentAccount, 'account_index' => $accountIndex, 'form' => $form->createView())))); } } } return $this->render($this->getTemplate('transfer.html.twig'), array('client' => $client, 'account' => $account, 'transfer_accounts' => $transferAccounts, 'current_account' => $currentAccount, 'account_index' => $accountIndex, 'information' => $information, 'form' => $form->createView())); }
public function updateTransferFormAction(Request $request) { $em = $this->get('doctrine.orm.entity_manager'); $adm = $this->get('wealthbot_docusign.account_docusign.manager'); $account = $em->getRepository('WealthbotClientBundle:ClientAccount')->find($request->get('account_id')); if (!$account || $account->getClient() != $this->getUser()) { return $this->getJsonResponse(array('status' => 'error', 'message' => 'Account does not exist.')); } $accountIndex = $request->get('account_index', 1); $consolidatedAccounts = $account->getConsolidatedAccountsCollection(); $transferAccounts = $consolidatedAccounts->getTransferAccounts(); if ($transferAccounts->isEmpty()) { $this->createNotFoundException('You have not transfer accounts.'); } if (!$transferAccounts->containsKey($accountIndex)) { throw $this->createNotFoundException('Page not found.'); } $currentAccount = $transferAccounts->get($accountIndex); $transferInfo = $currentAccount->getTransferInformation(); if (!$transferInfo) { $transferInfo = new TransferInformation(); $transferInfo->setClientAccount($currentAccount); } if ($request->isMethod('post')) { $form = $this->createForm(new TransferInformationFormType($adm, true), $transferInfo); $form->bind($request); /** @var TransferInformation $transferInfo */ $transferInfo = $form->getData(); $transferInfo->setStatementDocument(null); // Remove answer if it value is null /** @var TransferCustodianQuestionAnswer $answer */ foreach ($transferInfo->getQuestionnaireAnswers() as $answer) { if (null === $answer->getValue()) { $transferInfo->removeQuestionnaireAnswer($answer); } } $isDocusignAllowed = $adm->isDocusignAllowed($transferInfo, array(new TransferInformationCustodianCondition(), new TransferInformationPolicyCondition(), new TransferInformationQuestionnaireCondition(), new TransferInformationConsolidatorCondition())); $adm->setIsUsedDocusign($currentAccount, $isDocusignAllowed); $form = $this->createForm(new TransferInformationFormType($adm, true), $transferInfo); $formView = $form->createView(); return $this->getJsonResponse(array('status' => 'success', 'custodian_questions_fields' => $this->renderView('WealthbotClientBundle:Transfer:_transfer_form_custodian_questions_fields.html.twig', array('form' => $formView)), 'account_discrepancies_fields' => $this->renderView('WealthbotClientBundle:Transfer:_transfer_form_account_discrepancies_fields.html.twig', array('form' => $formView)))); } return $this->getJsonResponse(array('status' => 'error', 'message' => 'The operation failed due to some errors.')); }