code: public function onUpdate(ResourceEventInterface $event)
      {
          $invoice = $this->getInvoiceFromEvent($event);
  
          $this->preventForbiddenChange($invoice);
  
          // Generate number and key
          $changed = $this->generateNumber($invoice);
  
          // Updates the invoice data
          $changed |= $this->invoiceBuilder->update($invoice);
  
          // Updates the totals
          $changed |= $this->updateTotals($invoice);
  
          if ($this->persistenceHelper->isChanged($invoice, 'paymentMethod')) {
              $this->updateCustomerBalance($invoice);
          }
  
          if ($changed) {
              $this->persistenceHelper->persistAndRecompute($invoice, false);
  
              $this->scheduleSaleContentChangeEvent($this->getSaleFromInvoice($invoice));
          }
      }
docs: Update event handler.
  
  @param ResourceEventInterface $event