diff --git a/app/Console/Commands/ReactBuilder.php b/app/Console/Commands/ReactBuilder.php index 48dc2614d84c..6e8b3e10be61 100644 --- a/app/Console/Commands/ReactBuilder.php +++ b/app/Console/Commands/ReactBuilder.php @@ -48,8 +48,16 @@ class ReactBuilder extends Command { $includes = ''; - $directoryIterator = new \RecursiveDirectoryIterator(public_path('react/v'.config('ninja.app_version').'/'), \RecursiveDirectoryIterator::SKIP_DOTS); + $directoryIterator = false; + try { + $directoryIterator = new \RecursiveDirectoryIterator(public_path('react/v'.config('ninja.app_version').'/'), \RecursiveDirectoryIterator::SKIP_DOTS); + } + catch (\Exception $e) { + $this->error('React files not found'); + return; + } + foreach (new \RecursiveIteratorIterator($directoryIterator) as $file) { if ($file->getExtension() == 'js') { if (str_contains($file->getFileName(), 'index-')) { diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php index 3d7d11a2e1ea..3804ab890e94 100644 --- a/app/Http/Controllers/ClientPortal/InvoiceController.php +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -87,6 +87,12 @@ class InvoiceController extends Controller public function showBlob($hash) { $data = Cache::get($hash); + + if(!$data){ + usleep(200000); + $data = Cache::get($hash); + } + $invitation = false; match($data['entity_type'] ?? false){ diff --git a/app/Http/Livewire/PdfSlot.php b/app/Http/Livewire/PdfSlot.php index edb8c2e2aa5a..3ca80bd22eb7 100644 --- a/app/Http/Livewire/PdfSlot.php +++ b/app/Http/Livewire/PdfSlot.php @@ -59,11 +59,16 @@ class PdfSlot extends Component public function mount() { MultiDB::setDb($this->db); + + if(!$this->invitation) { + $this->entity->service()->createInvitations(); + $this->invitation = $this->entity->invitations()->first(); + } + } public function getPdf() { - // $this->pdf = $this->entity->fullscreenPdfViewer($this->invitation); $blob = [ 'entity_type' => $this->resolveEntityType(), @@ -74,7 +79,7 @@ class PdfSlot extends Component $hash = Str::random(64); - Cache::put($hash, $blob, now()->addMinutes(2)); + Cache::put($hash, $blob, 1800); $this->pdf = $hash; diff --git a/openapi/api-docs.yaml b/openapi/api-docs.yaml index 8b97f0483d21..4cdf30e82228 100644 --- a/openapi/api-docs.yaml +++ b/openapi/api-docs.yaml @@ -2766,11 +2766,15 @@ paths: parameters: - $ref: "#/components/parameters/X-Requested-With" requestBody: - description: "The template subject and body" + description: "Required fields to send an email" required: true content: application/json: schema: + required: + - entity + - entity_id + - template properties: subject: description: "The email subject" @@ -2784,9 +2788,13 @@ paths: entity_id: description: "The entity_id" type: string + cc_email: + description: "The email address of a user to be CC'd on the email" + type: string template: description: "The template required" type: string + example: invoice,quote,credit,purchase_order,payment,payment_partial,reminder1,reminder2,reminder3,reminder_endless type: object responses: 200: @@ -11226,7 +11234,22 @@ paths: tags: - invoices summary: "Create invoice" - description: "Adds a invoice to a company" + description: | + Adds a invoice to a company + + Triggered actions are available when updating or creating an invoice. + These are query parameters that can be chained in order to perform additional actions on the entity, these include: + + ``` + ?send_email=true [Saves and sends the invoice] + ?mark_sent=true [Saves and marks the invoice as sent] + ?paid=true [Saves and marks the invoice as paid] + ?amount_paid=100 [Saves and marks the invoice as paid with the given amount] + ?cancel=true [Saves and marks the invoice as cancelled] + ?save_default_footer=true [Saves the current footer as the default footer] + ?save_default_terms=true [Saves the current terms as the default terms] + ``` + operationId: storeInvoice parameters: - $ref: "#/components/parameters/X-API-TOKEN" @@ -11315,7 +11338,22 @@ paths: tags: - invoices summary: "Update invoice" - description: "Handles the updating of an invoice by id" + description: | + Handles the updating of an invoice by id. + + Triggered actions are available when updating or creating an invoice. + These are query parameters that can be chained in order to perform additional actions on the entity, these include: + + ``` + ?send_email=true [Saves and sends the invoice] + ?mark_sent=true [Saves and marks the invoice as sent] + ?paid=true [Saves and marks the invoice as paid] + ?amount_paid=100 [Saves and marks the invoice as paid with the given amount] + ?cancel=true [Saves and marks the invoice as cancelled] + ?save_default_footer=true [Saves the current footer as the default footer] + ?save_default_terms=true [Saves the current terms as the default terms] + ``` + operationId: updateInvoice parameters: - $ref: "#/components/parameters/X-API-TOKEN" @@ -16746,6 +16784,10 @@ components: description: 'Toggles charging taxes on custom surcharge amounts' type: boolean example: true + project_id: + description: 'The project associated with this invoice' + type: string + example: Opnel5aKBz type: object FillableInvoice: properties: @@ -19032,6 +19074,10 @@ components: description: 'Toggles charging taxes on custom surcharge amounts' type: boolean example: true + project_id: + description: 'The project associated with this invoice' + type: string + example: Opnel5aKBz type: object ClientRequest: required: diff --git a/openapi/components/schemas/invoice.yaml b/openapi/components/schemas/invoice.yaml index 8a237d4bd31c..bfe93d491ecc 100644 --- a/openapi/components/schemas/invoice.yaml +++ b/openapi/components/schemas/invoice.yaml @@ -219,4 +219,8 @@ description: 'Toggles charging taxes on custom surcharge amounts' type: boolean example: true + project_id: + description: 'The project associated with this invoice' + type: string + example: Opnel5aKBz type: object \ No newline at end of file diff --git a/openapi/components/schemas/invoice_request.yaml b/openapi/components/schemas/invoice_request.yaml index 1043f1b65060..083d8e3c9683 100644 --- a/openapi/components/schemas/invoice_request.yaml +++ b/openapi/components/schemas/invoice_request.yaml @@ -234,4 +234,8 @@ description: 'Toggles charging taxes on custom surcharge amounts' type: boolean example: true + project_id: + description: 'The project associated with this invoice' + type: string + example: Opnel5aKBz type: object \ No newline at end of file diff --git a/openapi/paths.yaml b/openapi/paths.yaml index 2e3e7fec4c8a..56d53f146b51 100644 --- a/openapi/paths.yaml +++ b/openapi/paths.yaml @@ -2742,11 +2742,15 @@ paths: parameters: - $ref: "#/components/parameters/X-Requested-With" requestBody: - description: "The template subject and body" + description: "Required fields to send an email" required: true content: application/json: schema: + required: + - entity + - entity_id + - template properties: subject: description: "The email subject" @@ -2760,9 +2764,13 @@ paths: entity_id: description: "The entity_id" type: string + cc_email: + description: "The email address of a user to be CC'd on the email" + type: string template: description: "The template required" type: string + example: invoice,quote,credit,purchase_order,payment,payment_partial,reminder1,reminder2,reminder3,reminder_endless type: object responses: 200: diff --git a/openapi/paths/invoices.yaml b/openapi/paths/invoices.yaml index ed25012fecda..38a995e874cd 100644 --- a/openapi/paths/invoices.yaml +++ b/openapi/paths/invoices.yaml @@ -132,7 +132,22 @@ tags: - invoices summary: "Create invoice" - description: "Adds a invoice to a company" + description: | + Adds a invoice to a company + + Triggered actions are available when updating or creating an invoice. + These are query parameters that can be chained in order to perform additional actions on the entity, these include: + + ``` + ?send_email=true [Saves and sends the invoice] + ?mark_sent=true [Saves and marks the invoice as sent] + ?paid=true [Saves and marks the invoice as paid] + ?amount_paid=100 [Saves and marks the invoice as paid with the given amount] + ?cancel=true [Saves and marks the invoice as cancelled] + ?save_default_footer=true [Saves the current footer as the default footer] + ?save_default_terms=true [Saves the current terms as the default terms] + ``` + operationId: storeInvoice parameters: - $ref: "#/components/parameters/X-API-TOKEN" @@ -221,7 +236,22 @@ tags: - invoices summary: "Update invoice" - description: "Handles the updating of an invoice by id" + description: | + Handles the updating of an invoice by id. + + Triggered actions are available when updating or creating an invoice. + These are query parameters that can be chained in order to perform additional actions on the entity, these include: + + ``` + ?send_email=true [Saves and sends the invoice] + ?mark_sent=true [Saves and marks the invoice as sent] + ?paid=true [Saves and marks the invoice as paid] + ?amount_paid=100 [Saves and marks the invoice as paid with the given amount] + ?cancel=true [Saves and marks the invoice as cancelled] + ?save_default_footer=true [Saves the current footer as the default footer] + ?save_default_terms=true [Saves the current terms as the default terms] + ``` + operationId: updateInvoice parameters: - $ref: "#/components/parameters/X-API-TOKEN" diff --git a/resources/views/portal/ninja2020/components/pdf-viewer.blade.php b/resources/views/portal/ninja2020/components/pdf-viewer.blade.php index 5b6cf228b379..307f4ea33f8c 100644 --- a/resources/views/portal/ninja2020/components/pdf-viewer.blade.php +++ b/resources/views/portal/ninja2020/components/pdf-viewer.blade.php @@ -46,7 +46,7 @@ -@livewire('pdf-slot', ['entity' => $entity, 'invitation' => $invitation, 'db' => $invitation->company->db]) +@livewire('pdf-slot', ['entity' => $entity, 'invitation' => $invitation, 'db' => $entity->company->db]) @if($mobile) @push('footer') diff --git a/resources/views/portal/ninja2020/credits/show.blade.php b/resources/views/portal/ninja2020/credits/show.blade.php index 47b093a299f7..2020a6e7d008 100644 --- a/resources/views/portal/ninja2020/credits/show.blade.php +++ b/resources/views/portal/ninja2020/credits/show.blade.php @@ -25,7 +25,7 @@ @include('portal.ninja2020.components.entity-documents', ['entity' => $credit]) -@livewire('pdf-slot', ['entity' => $credit, 'invitation' => $invitation, 'db' => $invitation->company->db]) +@livewire('pdf-slot', ['entity' => $credit, 'invitation' => $invitation, 'db' => $credit->company->db]) @endsection diff --git a/resources/views/portal/ninja2020/invoices/show.blade.php b/resources/views/portal/ninja2020/invoices/show.blade.php index b8db8405fbaa..74816efa8791 100644 --- a/resources/views/portal/ninja2020/invoices/show.blade.php +++ b/resources/views/portal/ninja2020/invoices/show.blade.php @@ -95,7 +95,7 @@ @endif @include('portal.ninja2020.components.entity-documents', ['entity' => $invoice]) - @livewire('pdf-slot', ['entity' => $invoice, 'invitation' => $invitation, 'db' => $invitation->company->db]) + @livewire('pdf-slot', ['entity' => $invoice, 'invitation' => $invitation, 'db' => $invoice->company->db]) @endsection diff --git a/resources/views/portal/ninja2020/purchase_orders/show.blade.php b/resources/views/portal/ninja2020/purchase_orders/show.blade.php index 5ebf38fe898b..98953d4afa22 100644 --- a/resources/views/portal/ninja2020/purchase_orders/show.blade.php +++ b/resources/views/portal/ninja2020/purchase_orders/show.blade.php @@ -46,7 +46,7 @@ @endif @include('portal.ninja2020.components.entity-documents', ['entity' => $purchase_order]) - @livewire('pdf-slot', ['entity' => $purchase_order, 'invitation' => $invitation, 'db' => $invitation->company->db]) + @livewire('pdf-slot', ['entity' => $purchase_order, 'invitation' => $invitation, 'db' => $purchase_order->company->db]) @endsection diff --git a/resources/views/portal/ninja2020/quotes/show.blade.php b/resources/views/portal/ninja2020/quotes/show.blade.php index ea71814fe624..f939ee5baa6a 100644 --- a/resources/views/portal/ninja2020/quotes/show.blade.php +++ b/resources/views/portal/ninja2020/quotes/show.blade.php @@ -100,7 +100,7 @@ @endif @include('portal.ninja2020.components.entity-documents', ['entity' => $quote]) - @livewire('pdf-slot', ['entity' => $quote, 'invitation' => $invitation, 'db' => $invitation->company->db]) + @livewire('pdf-slot', ['entity' => $quote, 'invitation' => $invitation, 'db' => $quote->company->db]) @endsection