/** * 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 details section tabs * * @return array */ protected function paymentDetailsSection() { $tabs = array(); $distributionTypeTab = new RadioGroupTab(); $distributionTypeTab->setGroupName('distribution_type')->setValue('partial_cash_distribution')->setSelected(true); $tabs[] = $distributionTypeTab; $amountTab = new TextTab(); $amountTab->setTabLabel('distribution_amount')->setValue($this->signableObject->getAmount()); $tabs[] = $amountTab; $startTransferDate = $this->signableObject->getTransferDate(); if ($startTransferDate) { $startDateTab = new TextTab(); $startDateTab->setTabLabel('distribution_start_date')->setValue($startTransferDate->format('m-d-Y')); $tabs[] = $startDateTab; return $tabs; } if ($this->signableObject->isOneTime()) { $frequency = 'one_time'; } else { switch ($this->signableObject->getFrequency()) { case Distribution::FREQUENCY_MONTHLY: $frequency = 'monthly'; break; case Distribution::FREQUENCY_QUARTERLY: $frequency = 'quarterly'; break; default: $frequency = ''; break; } } $frequencyTab = new RadioGroupTab(); $frequencyTab->setGroupName('distribution_frequency')->setValue($frequency)->setSelected(true); $tabs[] = $frequencyTab; 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); }