diff --git a/src/BondTransactionListBuilder.php b/src/BondTransactionListBuilder.php index 5b6f113193fb767f236fcaf5908d0a251d51598a..0615a3468bf08a2c1e55a2f7621faaa0aacacabd 100644 --- a/src/BondTransactionListBuilder.php +++ b/src/BondTransactionListBuilder.php @@ -118,16 +118,19 @@ class BondTransactionListBuilder extends EntityListBuilder { protected function getDefaultOperations(EntityInterface $entity) { $operations = parent::getDefaultOperations($entity); - $operations['wkf-validate'] = [ - 'title' => $this->t('Validate'), - 'weight' => 20, - 'url' => Url::fromRoute( - 'entity.bond_transaction.validate', - [ - 'entityId' => $entity->id(), - ] - ), - ]; + $state_value = $entity->get('state')->first(); + if ($state_value && $state_value->getWorkflowState()->canTransitionTo('valid')) { + $operations['wkf-validate'] = [ + 'title' => t('Validate'), + 'weight' => 20, + 'url' => Url::fromRoute( + 'entity.bond_transaction.validate', + [ + 'entityId' => $entity->id(), + ] + ), + ]; + } $destination = $this->redirectDestination->getAsArray(); foreach (array_keys($operations) as $key) { diff --git a/src/BondsInterest.php b/src/BondsInterest.php index 6d207a92201175ced07542531ff723fa0adc858a..e71e2d6888614ee6362d9dc8d692399da2df416a 100644 --- a/src/BondsInterest.php +++ b/src/BondsInterest.php @@ -87,6 +87,7 @@ class BondsInterest { if ($date === NULL) { $date = new DrupalDateTime(); } + $date->modify('first day of this month'); $result = []; $bond_ids = $this->entityTypeManager ->getStorage('shareholder_register_bond')