Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cesarockstar1985/b9d98b7e5eb85b41df2d6ae67a74a051 to your computer and use it in GitHub Desktop.
Save cesarockstar1985/b9d98b7e5eb85b41df2d6ae67a74a051 to your computer and use it in GitHub Desktop.
$bestMatchingSureties = $this->Quotes->Bonds->getBestMatchingSureties($quote->bond_id);
$rulesAutoapprove = [];
$bestMatchingSuretiesArray = $bestMatchingSureties->toArray();
$requestData = $this->request->getData();
foreach ($bestMatchingSureties->toArray()['all_sureties'] as $bestMatchingSurety) {
$this->Quotes->getConnection()->transactional(function () use ($bestMatchingSureties, $bestMatchingSurety, $quote, $requestData) {
$quote = $this->Quotes->selectSurety($requestData, $quote, $bestMatchingSurety);
$autoApprove = $this->Bonds->getMatchingSuretiesById($quote->bond_id, false, 'AutoApprove');
$dataAutoApprove = (int)Hash::get(array_values($autoApprove), '0.data.auto_approve');
if ($dataAutoApprove) {
$bestMatchingSurety->autoapprove = true;
}
return false;
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment