diff --git a/app/Console/Commands/CreateTestData.php b/app/Console/Commands/CreateTestData.php index 416c72fdab..087c511703 100644 --- a/app/Console/Commands/CreateTestData.php +++ b/app/Console/Commands/CreateTestData.php @@ -335,7 +335,7 @@ class CreateTestData extends Command $payment->invoices()->save($invoice); - event(new PaymentWasCreated($payment)); + event(new PaymentWasCreated($payment, $payment->company)); UpdateInvoicePayment::dispatchNow($payment, $payment->company); } diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index d295d93db0..cb97772575 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -61,7 +61,7 @@ class CompanySettings extends BaseSettings public $custom_message_paid_invoice = ''; public $custom_message_unapproved_quote = ''; public $auto_archive_quote = false; - public $auto_convert_quote = false; + public $auto_convert_quote = true; public $auto_email_invoice = true; public $inclusive_taxes = false; diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index a462cad626..1476757396 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -69,7 +69,52 @@ class BaseController extends Controller { $include = ''; - if(request()->input('include') !== null) + if(request()->has('first_load') && request()->input('first_load') == 'true') + { + + if(auth()->user()->getCompany()->clients->count() > 1000) + { + $include = [ + 'account', + 'user.company_user', + 'token', + 'company.activities', + 'company.users.company_user', + 'company.tax_rates', + 'company.groups', + 'company.company_gateways.gateway', + // 'company.clients', + // 'company.products', + // 'company.invoices', + // 'company.payments', + // 'company.quotes', + ]; + } + else + { + $include = [ + 'account', + 'user.company_user', + 'token', + 'company.activities', + 'company.users.company_user', + 'company.tax_rates', + 'company.groups', + 'company.company_gateways.gateway', + 'company.clients', + 'company.products', + 'company.invoices', + 'company.payments', + 'company.quotes', + ]; + } + + $include = array_merge($this->forced_includes, $include); + + $include = implode(",", $include); + + } + else if(request()->input('include') !== null) { $request_include = explode(",", request()->input('include')); diff --git a/app/Jobs/Invoice/StoreInvoice.php b/app/Jobs/Invoice/StoreInvoice.php index 41f2e9588d..1e9e8ca843 100644 --- a/app/Jobs/Invoice/StoreInvoice.php +++ b/app/Jobs/Invoice/StoreInvoice.php @@ -53,14 +53,14 @@ class StoreInvoice implements ShouldQueue * We expect the Invoice object along with * the request in array form * - * Embedded in the request may be additionals - * attributes which require additional work to be + * Embedded in the request may be additional + * attributes which require additional work to be * done in this job, these include - but are not limited to: * * 1. email_invoice - Email the Invoice * 2. mark_paid - Mark the invoice as paid (Generates a payment against the invoice) * 3. ...... - * + * * @return NULL|Invoice */ public function handle(InvoiceRepository $invoice_repo) : ?Invoice @@ -76,8 +76,8 @@ class StoreInvoice implements ShouldQueue // $this->invoice = $invoice_repo->markSent($this->invoice); // //fire autobill - todo - the PAYMENT class will update the INVOICE status. - // // $payment = - + // // $payment = + // } if(isset($this->data['email_invoice']) && (bool)$this->data['email_invoice']) @@ -97,7 +97,7 @@ class StoreInvoice implements ShouldQueue // generate a manual payment against the invoice // the PAYMENT class will update the INVOICE status. - //$payment = + //$payment = } @@ -106,7 +106,7 @@ class StoreInvoice implements ShouldQueue { //fire payment notifications here PaymentNotification::dispatch($payment, $payment->company); - + } if(isset($data['download_invoice']) && (bool)$this->data['download_invoice']) diff --git a/app/Jobs/Product/UpdateOrCreateProduct.php b/app/Jobs/Product/UpdateOrCreateProduct.php index 04ee4ab865..1dd085ee3f 100644 --- a/app/Jobs/Product/UpdateOrCreateProduct.php +++ b/app/Jobs/Product/UpdateOrCreateProduct.php @@ -39,6 +39,7 @@ class UpdateOrCreateProduct implements ShouldQueue { $this->products = $products; + $this->invoice = $invoice; } @@ -60,6 +61,8 @@ class UpdateOrCreateProduct implements ShouldQueue $product->product_key = $item->product_key; $product->notes = $item->notes; $product->cost = $item->cost; + $product->price = $item->price; + $product->quantity = $item->quantity; $product->tax_name1 = $item->tax_name1; $product->tax_rate1 = $item->tax_rate1; $product->tax_name2 = $item->tax_name2; diff --git a/app/Listeners/Invoice/CreateInvoicePdf.php b/app/Listeners/Invoice/CreateInvoicePdf.php index f136bfee85..ecf3ce4d3f 100644 --- a/app/Listeners/Invoice/CreateInvoicePdf.php +++ b/app/Listeners/Invoice/CreateInvoicePdf.php @@ -35,6 +35,6 @@ class CreateInvoicePdf implements ShouldQueue */ public function handle($event) { - PdfCreator::dispatch($event->invoice); + PdfCreator::dispatch($event->invoice, $event->company); } } diff --git a/app/Models/Client.php b/app/Models/Client.php index de3f025b30..535ce1b1ca 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -95,7 +95,7 @@ class Client extends BaseModel // 'primary_contact', 'country', // 'shipping_country', - 'company' + // 'company' ]; protected $casts = [