Skip to content

Instantly share code, notes, and snippets.

$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');
public function selectSurety($requestData, Quote $quote, BestMatchingSuretyResult $bestMatchingSurety): Quote
{
$data = [
'surety_id' => $requestData['surety_id'] ?? null,
'surety_rate' => $requestData['surety_rate'] ?? null,
'agent_id' => $requestData['agent_id'] ?? null,
'amount' => $requestData['amount'] ?? $quote->bond->bond_amount,
];
$quote = $this->patchEntity($quote, $data);
$suggested = $bestMatchingSurety->found;
protected function setupAdmin()
{
$this->_searchParameters = [];
parent::setupAdmin();
$fields = [
'underwriter' => [
'url' => [
'controller' => 'Underwriters',
'action' => 'view'
$responsiveFields = [
'underwriter',
'bonds',
'bonds_written',
'closing_ratio',
];
$this->Admin->setConfig('pageSubtitle', ['index' => __('Get Claim and Bond totals, grouped by Underwriters')]);
$this->Admin->setConfig('pageIcon', ['index' => 'building-o']);
$this->Admin->setConfig('headers', $headers);
$responsiveFields = [
'agency' => '',
'bonds' => '',
'bonds_written' => 'd-none d-sm-table-cell',
'closing_ratio' => 'd-none d-sm-table-cell',
'quoted' => 'd-none d-sm-table-cell',
'net' => 'd-none d-md-table-cell',
'surety_gross' => 'd-none d-md-table-cell',
'surety_net' => 'd-none d-md-table-cell',
'claims_amount' => 'd-none d-lg-table-cell',
<?php
/**
* @var \App\View\AppView $this
*/
if (isset($cmsPage) && !empty($cmsPage->jsonld)) {
$ldJson = json_decode($cmsPage->jsonld, true);
} elseif (!empty($bondType)) {
$ldJson = [
<?php
/**
* @var \App\View\AppView $this
*/
if (isset($cmsPage) && !empty($cmsPage->jsonld)) {
$ldJson = json_decode($cmsPage->jsonld, true);
} elseif (!empty($bondType)) {
$ldJson = [
"@context" => "https://schema.org/",
foreach ($bestMatchingSureties->toArray() as $bestMatchingSurety) {
$this->Quotes->getConnection()->transactional(function () use ($bestMatchingSureties, $quote, $requestDataSurety, $bestMatchingSurety) {
$quote = $this->Quotes->selectSurety($requestDataSurety, $quote, $bestMatchingSureties);
$autoApprove = $this->Quotes->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;
$this->elements = [
'view' => [
'postfix' => [
'Bonds/associated_to_parent_bond_type',
'Admin/BondTypes/post_view',
'Audit/history_trail_and_note',
],
],
'edit' => [
'postfix' => [
foreach ($bestMatchingSureties->all_sureties as $bestMatchingSurety) {
$this->Quotes->getConnection()->transactional(function () use ($bestMatchingSureties, $quote, $requestDataSurety, $bestMatchingSurety) {
$quote = $this->Quotes->selectSurety($requestDataSurety, $quote, $bestMatchingSureties);
$autoApprove = $this->Quotes->Bonds->getMatchingSuretiesById($quote->bond_id, false, 'AutoApprove');
$dataAutoApprove = (int)Hash::get(array_values($autoApprove), '0.data.auto_approve');
$bestMatchingSurety->autoapprove = false;
if ($dataAutoApprove) {
$bestMatchingSurety->autoapprove = true;
}
return false;