public function confirmDocument(Document $invoice, User $user)
 {
     if ($invoice instanceof Invoice) {
         $numberPrefix = null;
         $numberNumber = null;
         $number = $this->settingsService->getNumberByUser($user);
         if ($number) {
             $numberNumber = $number->getStartNumber();
             $numberPrefix = $number->getPrefix();
         }
         $sysNr = $this->entityManager->getRepository(Invoice::getClass())->getNextDocumentNumber();
         $finalNumber = $numberNumber > $sysNr ? $numberNumber : $sysNr;
         $invoice->setDocumentNumber($finalNumber);
         $invoice->setPrefix($numberPrefix);
         $invoice->setFullNumber($numberPrefix . $finalNumber);
     }
     $invoice->setConfirmed(true);
     $invoice->setStatus(Invoice::STATUS_CONFIRMED);
     return $this->saveInvoice($invoice);
 }