/** * Generate collection of tabs * * @return TabCollection * @throws \RuntimeException * @throws \InvalidArgumentException */ public function generate() { if (!$this->signableObject instanceof Distribution || !$this->signableObject->isOneTime()) { throw new \InvalidArgumentException('Signable object must be one-time distribution.'); } if ($this->signableObject->getTransferMethod() !== Distribution::TRANSFER_METHOD_WIRE_TRANSFER) { throw new \RuntimeException('Invalid transfer method for one-time distribution.'); } $bankInformation = $this->signableObject->getBankInformation(); $clientAccount = $this->signableObject->getClientAccount(); $client = $clientAccount ? $clientAccount->getClient() : null; $companyInformation = $client ? $client->getRiaCompanyInformation() : null; $tabs = array(); $advisorCode = new TextTab(); $advisorCode->setTabLabel('advisor#')->setValue($this->getAdvisorCode($companyInformation)); $tabs[] = $advisorCode; $accountNumber = new TextTab(); $accountNumber->setTabLabel('account#')->setValue($clientAccount ? $clientAccount->getAccountNumber() : ''); $tabs[] = $accountNumber; $bankNameTab = new TextTab(); $bankNameTab->setTabLabel('bank_name')->setValue($bankInformation->getName()); $tabs[] = $bankNameTab; $bankPhoneTab = new TextTab(); $bankPhoneTab->setTabLabel('bank_phone_number')->setValue($bankInformation->getPhoneNumber()); $tabs[] = $bankPhoneTab; return new TabCollection($tabs); }
/** * Generate collection of tabs * * @return TabCollection * @throws \RuntimeException * @throws \InvalidArgumentException */ public function generate() { if (!$this->signableObject instanceof Distribution || !$this->signableObject->isOneTime()) { throw new \InvalidArgumentException('Signable object must be one-time distribution.'); } if ($this->signableObject->getTransferMethod() !== Distribution::TRANSFER_METHOD_RECEIVE_CHECK) { throw new \RuntimeException('Invalid transfer method for one-time distribution.'); } $clientAccount = $this->signableObject->getClientAccount(); $client = $clientAccount ? $clientAccount->getClient() : null; $companyInformation = $client ? $client->getRiaCompanyInformation() : null; $tabs = array(); $advisorCode = new TextTab(); $advisorCode->setTabLabel('advisor#')->setValue($this->getAdvisorCode($companyInformation)); $tabs[] = $advisorCode; $accountNumber = new TextTab(); $accountNumber->setTabLabel('account#')->setValue($clientAccount ? $clientAccount->getAccountNumber() : ''); $tabs[] = $accountNumber; $tabs += $this->accountInformationSection(); $tabs += $this->paymentDetailsSection(); $tabs += $this->deliveryDetailsSection(); $tabs += $this->frequencySection(); $tabs += $this->periodicDetailsSection(); return new TabCollection($tabs); }
/** * Create tab configuration object * * @return TabsConfigurationInterface * @throws \InvalidArgumentException */ public function create() { $type = $this->signableObject->getDocumentSignatureType(); $account = $this->signableObject->getClientAccount(); $accountType = $account->getSystemType(); switch ($type) { case DocumentSignature::TYPE_OPEN_OR_TRANSFER_ACCOUNT: if ($accountType === SystemAccount::TYPE_ROTH_IRA || $accountType === SystemAccount::TYPE_TRADITIONAL_IRA) { $configuration = new IraAccountApplication($account); } else { $configuration = new PersonalAccountApplication($account); } break; case DocumentSignature::TYPE_TRANSFER_INFORMATION: $configuration = new AccountTransferForm($account); break; case DocumentSignature::TYPE_AUTO_INVEST_CONTRIBUTION: case DocumentSignature::TYPE_ONE_TIME_CONTRIBUTION: $configuration = new ElectronicFundsTransferForm($this->signableObject); break; case DocumentSignature::TYPE_AUTO_DISTRIBUTION: if ($accountType === SystemAccount::TYPE_ROTH_IRA || $accountType === SystemAccount::TYPE_TRADITIONAL_IRA) { $configuration = new IraDistributionForm($this->signableObject); } else { $configuration = new ElectronicFundsTransferForm($this->signableObject); } break; case DocumentSignature::TYPE_CHANGE_BENEFICIARY: if (!$this->signableObject instanceof Beneficiary) { throw new \InvalidArgumentException(sprintf('Object must be instance of Beneficiary.')); } $configuration = new BeneficiaryDesignationForm($this->signableObject); break; case DocumentSignature::TYPE_ONE_TIME_DISTRIBUTION: if ($accountType === SystemAccount::TYPE_ROTH_IRA || $accountType === SystemAccount::TYPE_TRADITIONAL_IRA) { $configuration = new IraDistributionForm($this->signableObject); } else { if (!$this->signableObject instanceof Distribution || !$this->signableObject->isOneTime()) { throw new \InvalidArgumentException(sprintf('Object must be one-time distribution.')); } if (Distribution::TRANSFER_METHOD_RECEIVE_CHECK === $this->signableObject->getTransferMethod()) { $configuration = new CheckRequest($this->signableObject); } elseif (Distribution::TRANSFER_METHOD_WIRE_TRANSFER == $this->signableObject->getTransferMethod()) { $configuration = new WireInstructions($this->signableObject); } else { $configuration = new ElectronicFundsTransferForm($this->signableObject); } } break; default: throw new \InvalidArgumentException(sprintf('Invalid type: %s for signable document.', $type)); break; } return $configuration; }
/** * Generate payment method section tabs * * @return array */ protected function paymentMethodSection() { $clientAccount = $this->signableObject->getClientAccount(); $owner = $clientAccount->getPrimaryApplicant(); $paymentMethod = ''; $transferMethod = $this->signableObject->getTransferMethod(); if ($transferMethod === Distribution::TRANSFER_METHOD_RECEIVE_CHECK) { $paymentMethod = 'send_check'; $sendCheckMethodTab = new RadioGroupTab(); $sendCheckMethodTab->setGroupName('send_check_method')->setValue('us_first_class_mail')->setSelected(true); $tabs[] = $sendCheckMethodTab; $sendCheckTypeTab = new RadioGroupTab(); $sendCheckTypeTab->setGroupName('send_check_type')->setValue('address_of_record')->setSelected(true); $tabs[] = $sendCheckTypeTab; $nameTab = new TextTab(); $nameTab->setTabLabel('send_check_payee_name')->setValue($owner->getFullName()); $tabs[] = $nameTab; $addressTab = new TextTab(); $addressTab->setTabLabel('send_check_address')->setValue($owner->getStreet()); $tabs[] = $addressTab; $cityTab = new TextTab(); $cityTab->setTabLabel('send_check_city')->setValue($owner->getCity()); $tabs[] = $cityTab; $stateTab = new TextTab(); $stateTab->setTabLabel('send_check_state')->setValue($owner->getState()->getName()); $tabs[] = $stateTab; $zipTab = new TextTab(); $zipTab->setTabLabel('send_check_zip')->setValue($owner->getZip()); $tabs[] = $zipTab; } elseif ($transferMethod !== Distribution::TRANSFER_METHOD_NOT_FUNDING) { $paymentMethod = 'electronic'; $electronicType = $transferMethod === Distribution::TRANSFER_METHOD_WIRE_TRANSFER ? 'wire_transfer' : 'bank_transfer'; $electronicTypeTab = new RadioGroupTab(); $electronicTypeTab->setGroupName('electronic_type')->setValue($electronicType)->setSelected(true); $tabs[] = $electronicTypeTab; /** @var BankInformation $bankInformation */ $bankInformation = $this->signableObject->getBankInformation(); if ($bankInformation) { $isCheckingAccountType = $bankInformation->getAccountType() == BankInformation::ACCOUNT_TYPE_CHECK; $bankAccountTypeTab = new RadioGroupTab(); $bankAccountTypeTab->setGroupName('electronic_account_type')->setValue($isCheckingAccountType ? 'check' : 'saving')->setSelected(true); $tabs[] = $bankAccountTypeTab; $bankAccountTitleTab = new TextTab(); $bankAccountTitleTab->setTabLabel('electronic_bank_account_title')->setValue($bankInformation->getAccountTitle()); $tabs[] = $bankAccountTitleTab; $bankAccountNumberTab = new TextTab(); $bankAccountNumberTab->setTabLabel('electronic_bank_account_number')->setValue($bankInformation->getAccountNumber()); $tabs[] = $bankAccountNumberTab; $bankRoutingNumberTab = new TextTab(); $bankRoutingNumberTab->setTabLabel('electronic_bank_routing_number')->setValue($bankInformation->getRoutingNumber()); $tabs[] = $bankRoutingNumberTab; $bankNameTab = new TextTab(); $bankNameTab->setTabLabel('electronic_bank_name')->setValue($bankInformation->getName()); $tabs[] = $bankNameTab; } } $paymentMethodTab = new RadioGroupTab(); $paymentMethodTab->setGroupName('payment_method')->setValue($paymentMethod)->setSelected(true); $tabs[] = $paymentMethodTab; return $tabs; }
/** * Get docusign template for signable object * * @param SignableInterface $object * @return string * @throws \InvalidArgumentException * @throws \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ private function getTemplateForSignableObject(SignableInterface $object) { $type = $object->getDocumentSignatureType(); $accountType = $object->getClientAccount()->getSystemType(); switch ($type) { case DocumentSignature::TYPE_OPEN_OR_TRANSFER_ACCOUNT: if ($accountType === SystemAccount::TYPE_PERSONAL_INVESTMENT || $accountType === SystemAccount::TYPE_JOINT_INVESTMENT) { $key = 'personal_account'; } elseif ($accountType === SystemAccount::TYPE_ROTH_IRA || $accountType === SystemAccount::TYPE_TRADITIONAL_IRA) { $key = 'ira_account'; } else { throw new \InvalidArgumentException(sprintf('Invalid account type: %s', $accountType)); } break; case DocumentSignature::TYPE_TRANSFER_INFORMATION: $key = 'account_transfer_form'; break; case DocumentSignature::TYPE_AUTO_INVEST_CONTRIBUTION: case DocumentSignature::TYPE_ONE_TIME_CONTRIBUTION: $key = 'electronic_funds_transfer_form'; break; case DocumentSignature::TYPE_CHANGE_BENEFICIARY: $key = 'beneficiary_designation_form'; break; case DocumentSignature::TYPE_AUTO_DISTRIBUTION: if ($accountType === SystemAccount::TYPE_PERSONAL_INVESTMENT || $accountType === SystemAccount::TYPE_JOINT_INVESTMENT) { $key = 'electronic_funds_transfer_form'; } elseif ($accountType === SystemAccount::TYPE_ROTH_IRA || $accountType === SystemAccount::TYPE_TRADITIONAL_IRA) { $key = 'ira_distribution_form'; } else { throw new \InvalidArgumentException(sprintf('Invalid account type: %s', $accountType)); } break; case DocumentSignature::TYPE_ONE_TIME_DISTRIBUTION: if ($accountType === SystemAccount::TYPE_PERSONAL_INVESTMENT || $accountType === SystemAccount::TYPE_JOINT_INVESTMENT) { if (!$object instanceof Distribution || !$object->isOneTime()) { throw new \InvalidArgumentException(sprintf('Object must be one-time distribution.')); } if (Distribution::TRANSFER_METHOD_RECEIVE_CHECK === $object->getTransferMethod()) { $key = 'check_request'; } elseif (Distribution::TRANSFER_METHOD_WIRE_TRANSFER == $object->getTransferMethod()) { $key = 'wire_instructions'; } else { $key = 'electronic_funds_transfer_form'; } } elseif ($accountType === SystemAccount::TYPE_ROTH_IRA || $accountType === SystemAccount::TYPE_TRADITIONAL_IRA) { $key = 'ira_distribution_form'; } else { throw new \InvalidArgumentException(sprintf('Invalid account type: %s', $accountType)); } break; default: throw new \InvalidArgumentException(sprintf('Invalid document signature type: %s', $type)); break; } if (!$this->hasTemplate($key)) { throw new InvalidConfigurationException('Template with key: %s does not exist. Check configuration.', $key); } return $this->getTemplate($key); }