mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01: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);
|
||||
break;
|
||||
case 'email':
|
||||
$this->quote->service()->sendEmail();
|
||||
$quote->service()->sendEmail();
|
||||
return response()->json(['message'=>'email sent'], 200);
|
||||
break;
|
||||
case 'mark_sent':
|
||||
|
@ -94,12 +94,16 @@ class EmailInvoice extends BaseMailerJob implements ShouldQueue
|
||||
}
|
||||
|
||||
if (count(Mail::failures()) > 0) {
|
||||
return $this->logMailError(Mail::failures(), $this->invoice->client);
|
||||
$this->logMailError(Mail::failures(), $this->invoice->client);
|
||||
}
|
||||
else{
|
||||
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) {
|
||||
return $this->logMailError(Mail::failures());
|
||||
}
|
||||
|
||||
$this->quote_invitation->quote->markSent()->save();
|
||||
|
||||
}
|
||||
|
||||
private function logMailError($errors)
|
||||
|
@ -122,6 +122,11 @@ class Credit extends BaseModel
|
||||
return $this->belongsTo(User::class, 'assigned_user_id', 'id');
|
||||
}
|
||||
|
||||
public function history()
|
||||
{
|
||||
return $this->hasManyThrough(Backup::class, Activity::class);
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
|
@ -127,6 +127,11 @@ class Quote extends BaseModel
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function history()
|
||||
{
|
||||
return $this->hasManyThrough(Backup::class, Activity::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class)->withTrashed();
|
||||
|
@ -11,11 +11,13 @@
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Backup;
|
||||
use App\Models\Credit;
|
||||
use App\Models\CreditInvitation;
|
||||
use App\Models\Document;
|
||||
use App\Transformers\CreditInvitationTransformer;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use App\Transformers\InvoiceHistoryTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class CreditTransformer extends EntityTransformer
|
||||
@ -25,15 +27,23 @@ class CreditTransformer extends EntityTransformer
|
||||
protected $defaultIncludes = [
|
||||
'invitations',
|
||||
'documents',
|
||||
'history',
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
'invitations',
|
||||
// 'payments',
|
||||
'history',
|
||||
// 'client',
|
||||
'documents',
|
||||
];
|
||||
|
||||
public function includeHistory(Credit $credit)
|
||||
{
|
||||
$transformer = new InvoiceHistoryTransformer($this->serializer);
|
||||
|
||||
return $this->includeCollection($credit->history, $transformer, Backup::class);
|
||||
}
|
||||
|
||||
public function includeInvitations(Credit $credit)
|
||||
{
|
||||
$transformer = new CreditInvitationTransformer($this->serializer);
|
||||
|
@ -11,7 +11,9 @@
|
||||
|
||||
namespace App\Transformers;
|
||||
|
||||
use App\Models\Activity;
|
||||
use App\Models\Backup;
|
||||
use App\Transformers\ActivityTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
class InvoiceHistoryTransformer extends EntityTransformer
|
||||
@ -19,9 +21,11 @@ class InvoiceHistoryTransformer extends EntityTransformer
|
||||
use MakesHash;
|
||||
|
||||
protected $defaultIncludes = [
|
||||
'activity'
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
'activity'
|
||||
];
|
||||
|
||||
public function transform(Backup $backup)
|
||||
@ -35,4 +39,11 @@ class InvoiceHistoryTransformer extends EntityTransformer
|
||||
'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;
|
||||
|
||||
use App\Models\Backup;
|
||||
use App\Models\Document;
|
||||
use App\Models\Quote;
|
||||
use App\Models\QuoteInvitation;
|
||||
use App\Transformers\DocumentTransformer;
|
||||
use App\Transformers\InvoiceHistoryTransformer;
|
||||
use App\Transformers\QuoteInvitationTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
|
||||
@ -25,15 +27,24 @@ class QuoteTransformer extends EntityTransformer
|
||||
protected $defaultIncludes = [
|
||||
'invitations',
|
||||
'documents',
|
||||
'history'
|
||||
];
|
||||
|
||||
protected $availableIncludes = [
|
||||
'invitations',
|
||||
'documents',
|
||||
'history'
|
||||
// 'payments',
|
||||
// 'client',
|
||||
];
|
||||
|
||||
public function includeHistory(Quote $quote)
|
||||
{
|
||||
$transformer = new InvoiceHistoryTransformer($this->serializer);
|
||||
|
||||
return $this->includeCollection($quote->history, $transformer, Backup::class);
|
||||
}
|
||||
|
||||
public function includeInvitations(Quote $quote)
|
||||
{
|
||||
$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…
Reference in New Issue
Block a user