new API endpoint to save invoice meta-fields (#5916)
This commit is contained in:
@@ -13,7 +13,7 @@ use App\Entity\Customer;
|
||||
use App\Entity\Invoice;
|
||||
use App\Entity\InvoiceTemplate;
|
||||
use App\Entity\Project;
|
||||
use App\Invoice\ServiceInvoice;
|
||||
use App\Invoice\InvoiceService;
|
||||
use App\Repository\CustomerRepository;
|
||||
use App\Repository\InvoiceTemplateRepository;
|
||||
use App\Repository\ProjectRepository;
|
||||
@@ -41,7 +41,7 @@ final class InvoiceCreateCommand extends Command
|
||||
private bool $previewUniqueFile = false;
|
||||
|
||||
public function __construct(
|
||||
private readonly ServiceInvoice $serviceInvoice,
|
||||
private readonly InvoiceService $InvoiceService,
|
||||
private readonly CustomerRepository $customerRepository,
|
||||
private readonly ProjectRepository $projectRepository,
|
||||
private readonly InvoiceTemplateRepository $invoiceTemplateRepository,
|
||||
@@ -283,16 +283,16 @@ final class InvoiceCreateCommand extends Command
|
||||
$query->setTemplate($tpl);
|
||||
|
||||
try {
|
||||
$model = $this->serviceInvoice->createModel($query);
|
||||
$model = $this->InvoiceService->createModel($query);
|
||||
// this check makes sure to only fetch invoices with records
|
||||
if (\count($model->getEntries()) === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null !== $this->previewDirectory) {
|
||||
$invoices[] = $this->saveInvoicePreview($this->serviceInvoice->renderInvoice($model, $this->eventDispatcher));
|
||||
$invoices[] = $this->saveInvoicePreview($this->InvoiceService->renderInvoice($model, $this->eventDispatcher));
|
||||
} else {
|
||||
$invoices[] = $this->serviceInvoice->createInvoice($model, $this->eventDispatcher);
|
||||
$invoices[] = $this->InvoiceService->createInvoice($model, $this->eventDispatcher);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$io->error(\sprintf('Failed to create invoice for project with: %s', $ex->getMessage()));
|
||||
@@ -358,16 +358,16 @@ final class InvoiceCreateCommand extends Command
|
||||
$query->setTemplate($tpl);
|
||||
|
||||
try {
|
||||
$model = $this->serviceInvoice->createModel($query);
|
||||
$model = $this->InvoiceService->createModel($query);
|
||||
// this check makes sure to only fetch invoices with records
|
||||
if (\count($model->getEntries()) === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null !== $this->previewDirectory) {
|
||||
$invoices[] = $this->saveInvoicePreview($this->serviceInvoice->renderInvoice($model, $this->eventDispatcher));
|
||||
$invoices[] = $this->saveInvoicePreview($this->InvoiceService->renderInvoice($model, $this->eventDispatcher));
|
||||
} else {
|
||||
$invoices[] = $this->serviceInvoice->createInvoice($model, $this->eventDispatcher);
|
||||
$invoices[] = $this->InvoiceService->createInvoice($model, $this->eventDispatcher);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$io->error(\sprintf('Failed to create invoice for customer with: %s', $ex->getMessage()));
|
||||
@@ -413,7 +413,7 @@ final class InvoiceCreateCommand extends Command
|
||||
$table->setHeaders($columns);
|
||||
|
||||
foreach ($invoices as $invoice) {
|
||||
$file = $this->serviceInvoice->getInvoiceFile($invoice);
|
||||
$file = $this->InvoiceService->getInvoiceFile($invoice);
|
||||
if (null === $file) {
|
||||
$io->warning(
|
||||
\sprintf('Created invoice with ID %s, but file was not found %s', $invoice->getId() ?? 'unknown', $invoice->getInvoiceFilename() ?? 'unknown')
|
||||
@@ -456,7 +456,7 @@ final class InvoiceCreateCommand extends Command
|
||||
*/
|
||||
private function getActiveCustomers(InvoiceQuery $invoiceQuery): array
|
||||
{
|
||||
$results = $this->serviceInvoice->getInvoiceItems($invoiceQuery);
|
||||
$results = $this->InvoiceService->getInvoiceItems($invoiceQuery);
|
||||
|
||||
$customers = [];
|
||||
|
||||
@@ -473,7 +473,7 @@ final class InvoiceCreateCommand extends Command
|
||||
*/
|
||||
private function getActiveProjects(InvoiceQuery $invoiceQuery): array
|
||||
{
|
||||
$results = $this->serviceInvoice->getInvoiceItems($invoiceQuery);
|
||||
$results = $this->InvoiceService->getInvoiceItems($invoiceQuery);
|
||||
|
||||
$projects = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user