/** * 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; }
public function isDocumentSignatureForObjectExist(SignableInterface $object) { $signature = $this->findOneDocumentSignatureBySourceIdAndType($object->getSourceObjectId(), $object->getDocumentSignatureType()); return $signature ? true : false; }
/** * 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); }