/**
  * @param \Magento\Sales\Api\Data\InvoiceInterface|\Magento\Sales\Api\Data\CreditmemoInterface $entity
  * @param \ClassyLlama\AvaTax\Api\Data\GetTaxResponseInterface $processSalesResponse
  */
 protected function updateAdditionalEntityAttributes($entity, GetTaxResponseInterface $processSalesResponse)
 {
     $entityExtension = $entity->getExtensionAttributes();
     if ($entityExtension == null) {
         $entityExtension = $this->getEntityExtensionInterface($entity);
     }
     // check to see if the AvataxIsUnbalanced is already set on this entity
     $avataxIsUnbalancedToSave = false;
     if ($entityExtension->getAvataxIsUnbalanced() === null) {
         $entityExtension->setAvataxIsUnbalanced($processSalesResponse->getIsUnbalanced());
         $avataxIsUnbalancedToSave = true;
     } else {
         // check to see if any existing value is different from the new value
         if ($processSalesResponse->getIsUnbalanced() != $entityExtension->getAvataxIsUnbalanced()) {
             // Log the warning
             $this->avaTaxLogger->warning(__('When processing an entity in the queue there was an existing AvataxIsUnbalanced and ' . 'the new value was different than the old one. The old value was overwritten.'), ['old_is_unbalanced' => $entityExtension->getAvataxIsUnbalanced(), 'new_is_unbalanced' => $processSalesResponse->getIsUnbalanced()]);
             $entityExtension->setAvataxIsUnbalanced($processSalesResponse->getIsUnbalanced());
             $avataxIsUnbalancedToSave = true;
         }
     }
     // check to see if the BaseAvataxTaxAmount is already set on this entity
     $baseAvataxTaxAmountToSave = false;
     if ($entityExtension->getBaseAvataxTaxAmount() === null) {
         $entityExtension->setBaseAvataxTaxAmount($processSalesResponse->getBaseAvataxTaxAmount());
         $baseAvataxTaxAmountToSave = true;
     } else {
         // check to see if any existing value is different from the new value
         if ($processSalesResponse->getBaseAvataxTaxAmount() != $entityExtension->getBaseAvataxTaxAmount()) {
             // Log the warning
             $this->avaTaxLogger->warning(__('When processing an entity in the queue there was an existing BaseAvataxTaxAmount and ' . 'the new value was different than the old one. The old value was overwritten.'), ['old_base_avatax_tax_amount' => $entityExtension->getBaseAvataxTaxAmount(), 'new_base_avatax_tax_amount' => $processSalesResponse->getBaseAvataxTaxAmount()]);
             $entityExtension->setBaseAvataxTaxAmount($processSalesResponse->getBaseAvataxTaxAmount());
             $baseAvataxTaxAmountToSave = true;
         }
     }
     // save the ExtensionAttributes on the entity object
     if ($avataxIsUnbalancedToSave || $baseAvataxTaxAmountToSave) {
         $entity->setExtensionAttributes($entityExtension);
         // get the repository for this entity type
         $entityRepository = $this->getEntityRepository($entity);
         // save the entity object using the repository
         $entityRepository->save($entity);
     }
 }