mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Working on invitationsg
This commit is contained in:
parent
866111cbbb
commit
32ca69bc52
@ -32,7 +32,7 @@ class InvoiceToRecurringInvoiceFactory
|
||||
$recurring_invoice->terms = $invoice->terms;
|
||||
$recurring_invoice->public_notes = $invoice->public_notes;
|
||||
$recurring_invoice->private_notes = $invoice->private_notes;
|
||||
$recurring_invoice->invoice_date = date_create()->format('Y-m-d');
|
||||
$recurring_invoice->invoice_date = date_create()->format(config('ninja.date_format'));
|
||||
$recurring_invoice->due_date = $invoice->due_date; //todo calculate based on terms
|
||||
$recurring_invoice->is_deleted = $invoice->is_deleted;
|
||||
$recurring_invoice->line_items = $invoice->line_items;
|
||||
|
@ -30,7 +30,7 @@ class RecurringInvoiceToInvoiceFactory
|
||||
$invoice->terms = $recurringinvoice->terms;
|
||||
$invoice->public_notes = $recurringinvoice->public_notes;
|
||||
$invoice->private_notes = $recurringinvoice->private_notes;
|
||||
$invoice->invoice_date = date_create()->format('Y-m-d');
|
||||
$invoice->invoice_date = date_create()->format(config('ninja.date_format'));
|
||||
$invoice->due_date = $recurringinvoice->due_date; //todo calculate based on terms
|
||||
$invoice->is_deleted = $recurringinvoice->is_deleted;
|
||||
$invoice->line_items = $recurringinvoice->line_items;
|
||||
|
@ -85,7 +85,7 @@ class ApplyPaymentToInvoice implements ShouldQueue
|
||||
|
||||
|
||||
if(!$this->invoice->due_date)
|
||||
$this->invoice->due_date = Carbon::now()->addDays($this->invoice->settings->payment_terms)->format('Y-m-d');
|
||||
$this->invoice->due_date = Carbon::now()->addDays($this->invoice->settings->payment_terms)->format(config('ninja.date_format'));
|
||||
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Invoice extends BaseModel
|
||||
{
|
||||
@ -155,5 +156,9 @@ class Invoice extends BaseModel
|
||||
return strtotime($this->createClientDate(date(), $this->client->timezone()->name)) > (strtotime($due_date) + (60 * 60 * 24));
|
||||
}
|
||||
|
||||
public function markViewed()
|
||||
{
|
||||
$this->last_viewed = Carbon::now()->format('Y-m-d H:i');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -96,8 +96,13 @@ class InvoiceRepository extends BaseRepository
|
||||
private function markInvitationsSent(Invoice $invoice) :Invoice
|
||||
{
|
||||
$invoice->invitations->each(function($invitation, $key) {
|
||||
$invitation->sent_date = Carbon::now()->format('Y-m-d H:i');
|
||||
$invitation->save();
|
||||
|
||||
if(!isset($invitation->sent_date))
|
||||
{
|
||||
$invitation->sent_date = Carbon::now()->format('Y-m-d H:i');
|
||||
$invitation->save();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -115,7 +120,7 @@ class InvoiceRepository extends BaseRepository
|
||||
|
||||
$invitation = InvoiceInvitation::whereClientContactId($contact->id)->whereInvoiceId($invoice->id)->first();
|
||||
|
||||
if($!invitation){
|
||||
if(!$invitation){
|
||||
$invitation = InvoiceInvitationFactory::create($invoice->company_id, $invoice->user_id);
|
||||
$invitation->client_contact_id = $contact->id;
|
||||
$invitation->invoice_id = $invoice->id;
|
||||
|
@ -307,7 +307,7 @@ trait GeneratesCounter
|
||||
}
|
||||
|
||||
$settings = $client->company->settings;
|
||||
$settings->reset_counter_date = $reset_date->format('Y-m-d');
|
||||
$settings->reset_counter_date = $reset_date->format(config('ninja.date_format'));
|
||||
$settings->invoice_number_counter = 1;
|
||||
$settings->quote_number_counter = 1;
|
||||
$settings->credit_number_counter = 1;
|
||||
|
39
app/Utils/Traits/Inviteable.php
Normal file
39
app/Utils/Traits/Inviteable.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Utils\Traits;
|
||||
|
||||
/**
|
||||
* Class MakesDates
|
||||
* @package App\Utils\Traits
|
||||
*/
|
||||
trait Inviteable
|
||||
{
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
$status = '';
|
||||
|
||||
if(isset($this->sent_date))
|
||||
$status = ctrans('texts.invitation_status_sent');
|
||||
|
||||
if(isset($this->opened_date))
|
||||
$status = ctrans('texts.invitation_status_opened');
|
||||
|
||||
|
||||
if(isset($this->viewed_date))
|
||||
$status = ctrans('texts.invitation_status_viewed');
|
||||
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,8 @@ return [
|
||||
'api_secret' => env('API_SECRET', ''),
|
||||
'google_maps_api_key' => env('GOOGLE_MAPS_API_KEY'),
|
||||
'key_length' => 64,
|
||||
'date_format' => 'Y-m-d',
|
||||
'date_time_format' => 'Y-m-d H:i',
|
||||
|
||||
'environment' => env('NINJA_ENVIRONMENT', 'selfhost'), // 'hosted', 'development', 'selfhost', 'reseller'
|
||||
|
||||
|
@ -44,6 +44,14 @@ class RecurringInvoicesCronTest extends TestCase
|
||||
//spin up 5 valid and 1 invalid recurring invoices
|
||||
$recurring_invoices = RecurringInvoice::where('next_send_date', '<=', Carbon::now()->addMinutes(30))->get();
|
||||
|
||||
Log::error(Carbon::now()->addMinutes(30)->format(config('ninja.date_time_format')));
|
||||
|
||||
$recurring_invoices->each(function ($inv, $key) {
|
||||
|
||||
Log::error(Carbon::parse($inv->next_send_date)->format(config('ninja.date_time_format')));
|
||||
|
||||
});
|
||||
|
||||
$recurring_all = RecurringInvoice::all();
|
||||
|
||||
$this->assertEquals(5, $recurring_invoices->count());
|
||||
|
@ -89,40 +89,40 @@ trait MockAccountData
|
||||
UpdateCompanyLedgerWithInvoice::dispatchNow($this->invoice, $this->invoice->amount);
|
||||
|
||||
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
||||
$recurring_invoice->next_send_date = Carbon::now()->format('Y-m-d H:i');
|
||||
$recurring_invoice->next_send_date = Carbon::now()->format(config('ninja.date_time_format'));
|
||||
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
||||
$recurring_invoice->remaining_cycles = 2;
|
||||
$recurring_invoice->start_date = Carbon::now()->format('Y-m-d');
|
||||
$recurring_invoice->start_date = Carbon::now()->format(config('ninja.date_format'));
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client);
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
||||
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(2)->format('Y-m-d H:i');
|
||||
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(2)->format(config('ninja.date_time_format'));
|
||||
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
||||
$recurring_invoice->remaining_cycles = 2;
|
||||
$recurring_invoice->start_date = Carbon::now()->format('Y-m-d');
|
||||
$recurring_invoice->start_date = Carbon::now()->format(config('ninja.date_format'));
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client);
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
||||
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(10)->format('Y-m-d H:i');
|
||||
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(10)->format(config('ninja.date_time_format'));
|
||||
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
||||
$recurring_invoice->remaining_cycles = 2;
|
||||
$recurring_invoice->start_date = Carbon::now()->format('Y-m-d');
|
||||
$recurring_invoice->start_date = Carbon::now()->format(config('ninja.date_format'));
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client);
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
||||
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(15)->format('Y-m-d H:i');
|
||||
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(15)->format(config('ninja.date_time_format'));
|
||||
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
||||
$recurring_invoice->remaining_cycles = 2;
|
||||
$recurring_invoice->start_date = Carbon::now()->format('Y-m-d');
|
||||
$recurring_invoice->start_date = Carbon::now()->format(config('ninja.date_format'));
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client);
|
||||
@ -130,20 +130,20 @@ trait MockAccountData
|
||||
|
||||
|
||||
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
||||
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(20)->format('Y-m-d H:i');
|
||||
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(20)->format(config('ninja.date_time_format'));
|
||||
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
||||
$recurring_invoice->remaining_cycles = 2;
|
||||
$recurring_invoice->start_date = Carbon::now()->format('Y-m-d');
|
||||
$recurring_invoice->start_date = Carbon::now()->format(config('ninja.date_format'));
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client);
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
||||
$recurring_invoice->next_send_date = Carbon::now()->addDays(10)->format('Y-m-d H:i');
|
||||
$recurring_invoice->next_send_date = Carbon::now()->addDays(10)->format(config('ninja.date_time_format'));
|
||||
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
||||
$recurring_invoice->remaining_cycles = 2;
|
||||
$recurring_invoice->start_date = Carbon::now()->format('Y-m-d');
|
||||
$recurring_invoice->start_date = Carbon::now()->format(config('ninja.date_format'));
|
||||
$recurring_invoice->save();
|
||||
|
||||
$recurring_invoice->invoice_number = $this->getNextInvoiceNumber($this->invoice->client);
|
||||
|
Loading…
Reference in New Issue
Block a user