mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add new functions to Quote and PO-Service
This commit is contained in:
parent
99d6ac5a70
commit
8c06698980
@ -754,7 +754,7 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
|
||||
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/invoices/';
|
||||
}
|
||||
public function e_invoice_filepath($invitation): string
|
||||
public function e_document_filepath($invitation): string
|
||||
{
|
||||
$contact_key = $invitation->contact->contact_key;
|
||||
|
||||
|
@ -409,12 +409,12 @@ class InvoiceService
|
||||
$this->invoice->invitations->each(function ($invitation) {
|
||||
try {
|
||||
// if (Storage::disk(config('filesystems.default'))->exists($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"))) {
|
||||
Storage::disk(config('filesystems.default'))->delete($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"));
|
||||
Storage::disk(config('filesystems.default'))->delete($this->invoice->client->e_document_filepath($invitation).$this->invoice->getFileName("xml"));
|
||||
// }
|
||||
|
||||
// if (Ninja::isHosted() && Storage::disk('public')->exists($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"))) {
|
||||
if (Ninja::isHosted()) {
|
||||
Storage::disk('public')->delete($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"));
|
||||
Storage::disk('public')->delete($this->invoice->client->e_document_filepath($invitation).$this->invoice->getFileName("xml"));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
|
@ -11,7 +11,9 @@
|
||||
|
||||
namespace App\Services\PurchaseOrder;
|
||||
|
||||
use App\Jobs\EDocument\CreateEDocument;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class PurchaseOrderService
|
||||
@ -75,6 +77,32 @@ class PurchaseOrderService
|
||||
return (new GetPurchaseOrderPdf($this->purchase_order, $contact))->run();
|
||||
}
|
||||
|
||||
public function getEPurchaseOrder($contact = null)
|
||||
{
|
||||
return (new CreateEDocument($this->purchase_order))->handle();
|
||||
}
|
||||
public function deleteEPurchaseOrder()
|
||||
{
|
||||
$this->purchase_order->load('invitations');
|
||||
|
||||
$this->purchase_order->invitations->each(function ($invitation) {
|
||||
try {
|
||||
// if (Storage::disk(config('filesystems.default'))->exists($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"))) {
|
||||
Storage::disk(config('filesystems.default'))->delete($this->purchase_order->client->e_document_filepath($invitation).$this->purchase_order->getFileName("xml"));
|
||||
// }
|
||||
|
||||
// if (Ninja::isHosted() && Storage::disk('public')->exists($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"))) {
|
||||
if (Ninja::isHosted()) {
|
||||
Storage::disk('public')->delete($this->purchase_order->client->e_document_filepath($invitation).$this->purchase_order->getFileName("xml"));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->purchase_order->status_id = $status;
|
||||
|
@ -13,6 +13,7 @@ namespace App\Services\Quote;
|
||||
|
||||
use App\Events\Quote\QuoteWasApproved;
|
||||
use App\Exceptions\QuoteConversion;
|
||||
use App\Jobs\EDocument\CreateEDocument;
|
||||
use App\Models\Project;
|
||||
use App\Models\Quote;
|
||||
use App\Repositories\QuoteRepository;
|
||||
@ -72,6 +73,11 @@ class QuoteService
|
||||
return (new GetQuotePdf($this->quote, $contact))->run();
|
||||
}
|
||||
|
||||
public function getEQuote($contact = null)
|
||||
{
|
||||
return (new CreateEDocument($this->quote))->handle();
|
||||
}
|
||||
|
||||
public function sendEmail($contact = null): self
|
||||
{
|
||||
$send_email = new SendEmail($this->quote, null, $contact);
|
||||
@ -226,6 +232,27 @@ class QuoteService
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function deleteEQuote()
|
||||
{
|
||||
$this->quote->load('invitations');
|
||||
|
||||
$this->quote->invitations->each(function ($invitation) {
|
||||
try {
|
||||
// if (Storage::disk(config('filesystems.default'))->exists($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"))) {
|
||||
Storage::disk(config('filesystems.default'))->delete($this->quote->client->e_document_filepath($invitation).$this->quote->getFileName("xml"));
|
||||
// }
|
||||
|
||||
// if (Ninja::isHosted() && Storage::disk('public')->exists($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"))) {
|
||||
if (Ninja::isHosted()) {
|
||||
Storage::disk('public')->delete($this->quote->client->e_document_filepath($invitation).$this->quote->getFileName("xml"));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the quote.
|
||||
|
Loading…
x
Reference in New Issue
Block a user