mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 01:14:33 -04:00
Add reminder fields to entities
This commit is contained in:
parent
fd38a964e7
commit
3ac9cc5158
@ -675,7 +675,7 @@ class QuoteController extends BaseController
|
|||||||
return $this->listResponse($quote);
|
return $this->listResponse($quote);
|
||||||
break;
|
break;
|
||||||
case 'email':
|
case 'email':
|
||||||
$this->quote->service()->sendEmail();
|
$quote->service()->sendEmail();
|
||||||
return response()->json(['message'=>'email sent'], 200);
|
return response()->json(['message'=>'email sent'], 200);
|
||||||
break;
|
break;
|
||||||
case 'mark_sent':
|
case 'mark_sent':
|
||||||
|
@ -94,12 +94,16 @@ class EmailInvoice extends BaseMailerJob implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (count(Mail::failures()) > 0) {
|
if (count(Mail::failures()) > 0) {
|
||||||
return $this->logMailError(Mail::failures(), $this->invoice->client);
|
$this->logMailError(Mail::failures(), $this->invoice->client);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
event(new InvoiceWasEmailed($this->invoice_invitation, $this->company, Ninja::eventVars()));
|
event(new InvoiceWasEmailed($this->invoice_invitation, $this->company, Ninja::eventVars()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Mark invoice sent */
|
||||||
|
$this->invoice_invitation->invoice->service()->markSent()->save();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,6 +59,9 @@ class EmailQuote implements ShouldQueue
|
|||||||
if (count(Mail::failures()) > 0) {
|
if (count(Mail::failures()) > 0) {
|
||||||
return $this->logMailError(Mail::failures());
|
return $this->logMailError(Mail::failures());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->quote_invitation->quote->markSent()->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function logMailError($errors)
|
private function logMailError($errors)
|
||||||
|
@ -122,6 +122,11 @@ class Credit extends BaseModel
|
|||||||
return $this->belongsTo(User::class, 'assigned_user_id', 'id');
|
return $this->belongsTo(User::class, 'assigned_user_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function history()
|
||||||
|
{
|
||||||
|
return $this->hasManyThrough(Backup::class, Activity::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
|
@ -127,6 +127,11 @@ class Quote extends BaseModel
|
|||||||
return $this->belongsTo(Company::class);
|
return $this->belongsTo(Company::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function history()
|
||||||
|
{
|
||||||
|
return $this->hasManyThrough(Backup::class, Activity::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(User::class)->withTrashed();
|
return $this->belongsTo(User::class)->withTrashed();
|
||||||
|
@ -11,11 +11,13 @@
|
|||||||
|
|
||||||
namespace App\Transformers;
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Models\Backup;
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use App\Models\CreditInvitation;
|
use App\Models\CreditInvitation;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use App\Transformers\CreditInvitationTransformer;
|
use App\Transformers\CreditInvitationTransformer;
|
||||||
use App\Transformers\DocumentTransformer;
|
use App\Transformers\DocumentTransformer;
|
||||||
|
use App\Transformers\InvoiceHistoryTransformer;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
class CreditTransformer extends EntityTransformer
|
class CreditTransformer extends EntityTransformer
|
||||||
@ -25,15 +27,23 @@ class CreditTransformer extends EntityTransformer
|
|||||||
protected $defaultIncludes = [
|
protected $defaultIncludes = [
|
||||||
'invitations',
|
'invitations',
|
||||||
'documents',
|
'documents',
|
||||||
|
'history',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $availableIncludes = [
|
protected $availableIncludes = [
|
||||||
'invitations',
|
'invitations',
|
||||||
// 'payments',
|
'history',
|
||||||
// 'client',
|
// 'client',
|
||||||
'documents',
|
'documents',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function includeHistory(Credit $credit)
|
||||||
|
{
|
||||||
|
$transformer = new InvoiceHistoryTransformer($this->serializer);
|
||||||
|
|
||||||
|
return $this->includeCollection($credit->history, $transformer, Backup::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function includeInvitations(Credit $credit)
|
public function includeInvitations(Credit $credit)
|
||||||
{
|
{
|
||||||
$transformer = new CreditInvitationTransformer($this->serializer);
|
$transformer = new CreditInvitationTransformer($this->serializer);
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
namespace App\Transformers;
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Models\Activity;
|
||||||
use App\Models\Backup;
|
use App\Models\Backup;
|
||||||
|
use App\Transformers\ActivityTransformer;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
class InvoiceHistoryTransformer extends EntityTransformer
|
class InvoiceHistoryTransformer extends EntityTransformer
|
||||||
@ -19,9 +21,11 @@ class InvoiceHistoryTransformer extends EntityTransformer
|
|||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
protected $defaultIncludes = [
|
protected $defaultIncludes = [
|
||||||
|
'activity'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $availableIncludes = [
|
protected $availableIncludes = [
|
||||||
|
'activity'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function transform(Backup $backup)
|
public function transform(Backup $backup)
|
||||||
@ -35,4 +39,11 @@ class InvoiceHistoryTransformer extends EntityTransformer
|
|||||||
'updated_at' => (int)$backup->updated_at,
|
'updated_at' => (int)$backup->updated_at,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeActivity(Backup $backup)
|
||||||
|
{
|
||||||
|
$transformer = new ActivityTransformer($this->serializer);
|
||||||
|
|
||||||
|
return $this->includeCollection($backup->activity, $transformer, Activity::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,12 @@
|
|||||||
|
|
||||||
namespace App\Transformers;
|
namespace App\Transformers;
|
||||||
|
|
||||||
|
use App\Models\Backup;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
use App\Models\Quote;
|
use App\Models\Quote;
|
||||||
use App\Models\QuoteInvitation;
|
use App\Models\QuoteInvitation;
|
||||||
use App\Transformers\DocumentTransformer;
|
use App\Transformers\DocumentTransformer;
|
||||||
|
use App\Transformers\InvoiceHistoryTransformer;
|
||||||
use App\Transformers\QuoteInvitationTransformer;
|
use App\Transformers\QuoteInvitationTransformer;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
|
|
||||||
@ -25,15 +27,24 @@ class QuoteTransformer extends EntityTransformer
|
|||||||
protected $defaultIncludes = [
|
protected $defaultIncludes = [
|
||||||
'invitations',
|
'invitations',
|
||||||
'documents',
|
'documents',
|
||||||
|
'history'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $availableIncludes = [
|
protected $availableIncludes = [
|
||||||
'invitations',
|
'invitations',
|
||||||
'documents',
|
'documents',
|
||||||
|
'history'
|
||||||
// 'payments',
|
// 'payments',
|
||||||
// 'client',
|
// 'client',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function includeHistory(Quote $quote)
|
||||||
|
{
|
||||||
|
$transformer = new InvoiceHistoryTransformer($this->serializer);
|
||||||
|
|
||||||
|
return $this->includeCollection($quote->history, $transformer, Backup::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function includeInvitations(Quote $quote)
|
public function includeInvitations(Quote $quote)
|
||||||
{
|
{
|
||||||
$transformer = new QuoteInvitationTransformer($this->serializer);
|
$transformer = new QuoteInvitationTransformer($this->serializer);
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddReminderSentFieldsToEntityTables extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('activities', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('quote_id')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('quotes', function (Blueprint $table) {
|
||||||
|
$table->date('reminder1_sent')->nullable();
|
||||||
|
$table->date('reminder2_sent')->nullable();
|
||||||
|
$table->date('reminder3_sent')->nullable();
|
||||||
|
$table->date('reminder_last_sent')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('invoices', function (Blueprint $table) {
|
||||||
|
$table->date('reminder1_sent')->nullable();
|
||||||
|
$table->date('reminder2_sent')->nullable();
|
||||||
|
$table->date('reminder3_sent')->nullable();
|
||||||
|
$table->date('reminder_last_sent')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('credits', function (Blueprint $table) {
|
||||||
|
$table->date('reminder1_sent')->nullable();
|
||||||
|
$table->date('reminder2_sent')->nullable();
|
||||||
|
$table->date('reminder3_sent')->nullable();
|
||||||
|
$table->date('reminder_last_sent')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user