mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
commit
e4a65a07c8
@ -1 +1 @@
|
||||
5.3.37
|
||||
5.3.38
|
@ -67,20 +67,13 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
*/
|
||||
class CheckDb extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $signature = 'ninja:check-db';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check MultiDB';
|
||||
|
||||
|
||||
protected $log = '';
|
||||
|
||||
|
||||
private $entities = [
|
||||
Account::class,
|
||||
Activity::class,
|
||||
|
@ -56,13 +56,9 @@ use stdClass;
|
||||
class CreateSingleAccount extends Command
|
||||
{
|
||||
use MakesHash, GeneratesCounter;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $description = 'Create Single Sample Account';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
||||
protected $signature = 'ninja:create-single-account {gateway=all} {--database=db-ninja-01}';
|
||||
|
||||
protected $invoice_repo;
|
||||
@ -71,18 +67,6 @@ class CreateSingleAccount extends Command
|
||||
|
||||
protected $gateway;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @param InvoiceRepository $invoice_repo
|
||||
*/
|
||||
public function __construct(InvoiceRepository $invoice_repo)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->invoice_repo = $invoice_repo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
@ -94,6 +78,11 @@ class CreateSingleAccount extends Command
|
||||
if(config('ninja.is_docker'))
|
||||
return;
|
||||
|
||||
if (!$this->confirm('Are you sure you want to inject dummy data?'))
|
||||
return;
|
||||
|
||||
$this->invoice_repo = new InvoiceRepository();
|
||||
|
||||
MultiDB::setDb($this->option('database'));
|
||||
|
||||
$this->info(date('r').' Create Single Sample Account...');
|
||||
|
@ -59,18 +59,6 @@ class CreateTestData extends Command
|
||||
|
||||
protected $invoice_repo;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @param InvoiceRepository $invoice_repo
|
||||
*/
|
||||
public function __construct(InvoiceRepository $invoice_repo)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->invoice_repo = $invoice_repo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
@ -80,6 +68,11 @@ class CreateTestData extends Command
|
||||
{
|
||||
if(config('ninja.is_docker'))
|
||||
return;
|
||||
|
||||
if (!$this->confirm('Are you sure you want to inject dummy data?'))
|
||||
return;
|
||||
|
||||
$this->invoice_repo = new InvoiceRepository();
|
||||
|
||||
$this->info(date('r').' Running CreateTestData...');
|
||||
$this->count = $this->argument('count');
|
||||
|
@ -53,28 +53,15 @@ class DemoMode extends Command
|
||||
{
|
||||
use MakesHash, GeneratesCounter;
|
||||
|
||||
protected $name = 'ninja:demo-mode';
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'ninja:demo-mode';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Setup demo mode';
|
||||
|
||||
protected $invoice_repo;
|
||||
|
||||
public function __construct(InvoiceRepository $invoice_repo)
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->invoice_repo = $invoice_repo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,6 +76,8 @@ class DemoMode extends Command
|
||||
if(config('ninja.is_docker'))
|
||||
return;
|
||||
|
||||
$this->invoice_repo = new InvoiceRepository();
|
||||
|
||||
$cached_tables = config('ninja.cached_tables');
|
||||
|
||||
foreach ($cached_tables as $name => $class) {
|
||||
|
@ -39,7 +39,7 @@ class ParallelCheckData extends Command
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'ninja:pcheck-data';
|
||||
protected $signature = 'ninja:pcheck-data';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -17,7 +17,6 @@ use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class PostUpdate extends Command
|
||||
{
|
||||
protected $name = 'ninja:post-update';
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
|
@ -80,10 +80,14 @@ class Kernel extends ConsoleKernel
|
||||
/* Run hosted specific jobs */
|
||||
if (Ninja::isHosted()) {
|
||||
|
||||
$schedule->job(new AdjustEmailQuota)->dailyAt('23:00')->withoutOverlapping();
|
||||
$schedule->job(new AdjustEmailQuota)->dailyAt('23:30')->withoutOverlapping();
|
||||
|
||||
$schedule->job(new SendFailedEmails)->daily()->withoutOverlapping();
|
||||
$schedule->command('ninja:check-data --database=db-ninja-01')->daily()->withoutOverlapping();
|
||||
$schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('00:05')->withoutOverlapping();
|
||||
|
||||
$schedule->command('ninja:check-data --database=db-ninja-01')->daily('00:50')->withoutOverlapping();
|
||||
|
||||
$schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('00:55')->withoutOverlapping();
|
||||
|
||||
$schedule->command('ninja:s3-cleanup')->dailyAt('23:15')->withoutOverlapping();
|
||||
|
||||
}
|
||||
@ -91,6 +95,7 @@ class Kernel extends ConsoleKernel
|
||||
if(config('queue.default') == 'database' && Ninja::isSelfHost() && config('ninja.internal_queue_enabled') && !config('ninja.is_docker')) {
|
||||
|
||||
$schedule->command('queue:work')->everyMinute()->withoutOverlapping();
|
||||
|
||||
$schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping();
|
||||
|
||||
}
|
||||
|
@ -382,9 +382,7 @@ class ClientController extends BaseController
|
||||
/* Set the client country to the company if none is set */
|
||||
if(!$client->country_id && strlen($client->company->settings->country_id) > 1){
|
||||
|
||||
$client->country_id = $client->company->settings->country_id;
|
||||
|
||||
$client->save();
|
||||
$client->update(['country_id' => $client->company->settings->country_id]);
|
||||
|
||||
}
|
||||
|
||||
|
@ -204,8 +204,6 @@ class RecurringInvoiceController extends BaseController
|
||||
{
|
||||
$recurring_invoice = $this->recurring_invoice_repo->save($request->all(), RecurringInvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id));
|
||||
|
||||
event(new RecurringInvoiceWasCreated($recurring_invoice, $recurring_invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
$offset = $recurring_invoice->client->timezone_offset();
|
||||
$recurring_invoice->next_send_date = Carbon::parse($recurring_invoice->next_send_date)->startOfDay()->addSeconds($offset);
|
||||
$recurring_invoice->saveQuietly();
|
||||
@ -214,6 +212,8 @@ class RecurringInvoiceController extends BaseController
|
||||
->triggeredActions($request)
|
||||
->save();
|
||||
|
||||
event(new RecurringInvoiceWasCreated($recurring_invoice, $recurring_invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
return $this->itemResponse($recurring_invoice);
|
||||
}
|
||||
|
||||
|
@ -354,8 +354,6 @@ class SubscriptionController extends BaseController
|
||||
|
||||
event(new SubscriptionWasUpdated($subscription, $subscription->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
nlog($subscription->id);
|
||||
|
||||
return $this->itemResponse($subscription);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@ class CreateInvoiceActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class InvoiceArchivedActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class InvoiceCancelledActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -24,6 +24,8 @@ class InvoiceCreatedNotification implements ShouldQueue
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ class InvoiceDeletedActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class InvoiceEmailActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class InvoiceEmailFailedActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -24,6 +24,8 @@ class InvoiceEmailedNotification implements ShouldQueue
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ class InvoiceFailedEmailNotification
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
@ -43,8 +45,7 @@ class InvoiceFailedEmailNotification
|
||||
$first_notification_sent = true;
|
||||
|
||||
$invoice = $event->invitation->invoice;
|
||||
$invoice->last_sent_date = now();
|
||||
$invoice->save();
|
||||
$invoice->update(['last_sent_date' => now()]);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new NinjaMailer( (new EntityFailedSendObject($event->invitation, 'invoice', $event->template, $event->message))->build() );
|
||||
|
@ -21,6 +21,8 @@ class InvoicePaidActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -20,6 +20,8 @@ class InvoiceReminderEmailActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class InvoiceRestoredActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class InvoiceReversedActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class InvoiceViewedActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class UpdateInvoiceActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -16,6 +16,9 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class UpdateInvoiceInvitations implements ShouldQueue
|
||||
{
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -19,6 +19,8 @@ class PaymentEmailFailureActivity implements ShouldQueue
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -17,6 +17,8 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class PaymentEmailedActivity implements ShouldQueue
|
||||
{
|
||||
public $delay = 5;
|
||||
|
||||
use UserNotifies;
|
||||
|
||||
/**
|
||||
|
@ -26,6 +26,9 @@ class PaymentNotification implements ShouldQueue
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class PaymentRestoredActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class CreateQuoteInvitation implements ShouldQueue
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
|
@ -21,6 +21,8 @@ class QuoteApprovedActivity implements ShouldQueue
|
||||
{
|
||||
protected $activity_repo;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
|
@ -25,6 +25,8 @@ class QuoteApprovedNotification implements ShouldQueue
|
||||
{
|
||||
use UserNotifies;
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class QuoteApprovedWebhook implements ShouldQueue
|
||||
{
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ use stdClass;
|
||||
|
||||
class QuoteArchivedActivity implements ShouldQueue
|
||||
{
|
||||
public $delay = 5;
|
||||
|
||||
protected $activity_repo;
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,8 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class QuoteCreatedNotification implements ShouldQueue
|
||||
{
|
||||
public $delay = 5;
|
||||
|
||||
use UserNotifies;
|
||||
|
||||
public function __construct()
|
||||
|
@ -19,6 +19,8 @@ use stdClass;
|
||||
|
||||
class QuoteDeletedActivity implements ShouldQueue
|
||||
{
|
||||
public $delay = 5;
|
||||
|
||||
protected $activity_repo;
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,8 @@ use stdClass;
|
||||
|
||||
class QuoteEmailActivity implements ShouldQueue
|
||||
{
|
||||
public $delay = 5;
|
||||
|
||||
protected $activity_repo;
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,9 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class QuoteEmailedNotification implements ShouldQueue
|
||||
{
|
||||
|
||||
public $delay = 5;
|
||||
|
||||
use UserNotifies;
|
||||
|
||||
public function __construct()
|
||||
|
@ -19,6 +19,8 @@ use stdClass;
|
||||
|
||||
class QuoteRestoredActivity implements ShouldQueue
|
||||
{
|
||||
public $delay = 5;
|
||||
|
||||
protected $activity_repo;
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,8 @@ use stdClass;
|
||||
|
||||
class QuoteViewedActivity implements ShouldQueue
|
||||
{
|
||||
public $delay = 5;
|
||||
|
||||
protected $activity_repo;
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@ use App\Models\Company;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class DownloadBackup extends Mailable
|
||||
{
|
||||
@ -36,6 +37,8 @@ class DownloadBackup extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
App::setLocale($this->company->getLocale());
|
||||
|
||||
$company = Company::where('company_key', $this->company->company_key)->first();
|
||||
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
|
@ -113,10 +113,10 @@ class BaseModel extends Model
|
||||
* to persist the new settings we will also need to pass back a
|
||||
* reference to the parent class.
|
||||
*
|
||||
* @param mixes $key The key of property
|
||||
* @param $key The key of property
|
||||
* @return
|
||||
*/
|
||||
public function getSettingsByKey(mixes $key)
|
||||
public function getSettingsByKey($key)
|
||||
{
|
||||
/* Does Setting Exist @ client level */
|
||||
if (isset($this->getSettings()->{$key})) {
|
||||
|
@ -204,11 +204,13 @@ class BaseDriver extends AbstractPaymentDriver
|
||||
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($paid_invoices, 'invoice_id')))->withTrashed()->get();
|
||||
$payment->invoices()->sync($invoices);
|
||||
|
||||
$payment->service()->applyNumber()->save();
|
||||
|
||||
$invoices->each(function ($invoice) use ($payment) {
|
||||
event(new InvoiceWasPaid($invoice, $payment, $payment->company, Ninja::eventVars()));
|
||||
});
|
||||
|
||||
return $payment->service()->applyNumber()->save();
|
||||
return $payment;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,8 +265,7 @@ class BaseDriver extends AbstractPaymentDriver
|
||||
|
||||
event('eloquent.created: App\Models\Payment', $payment);
|
||||
|
||||
if ($this->client->getSetting('client_online_payment_notification') && in_array($status, [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING
|
||||
]))
|
||||
if ($this->client->getSetting('client_online_payment_notification') && in_array($status, [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING]))
|
||||
$payment->service()->sendEmail();
|
||||
|
||||
//todo
|
||||
|
@ -67,14 +67,13 @@ class ClientRepository extends BaseRepository
|
||||
|
||||
if (!isset($client->number) || empty($client->number) || strlen($client->number) == 0) {
|
||||
$client->number = $this->getNextClientNumber($client);
|
||||
$client->save();
|
||||
}
|
||||
|
||||
if (empty($data['name'])) {
|
||||
$data['name'] = $client->present()->name();
|
||||
}
|
||||
|
||||
$client->save();
|
||||
|
||||
$this->contact_repo->save($data, $client);
|
||||
|
||||
return $client;
|
||||
|
@ -37,8 +37,6 @@ class MarkSent
|
||||
|
||||
$this->credit->markInvitationsSent();
|
||||
|
||||
event(new CreditWasMarkedSent($this->credit, $this->credit->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
$this->credit
|
||||
->service()
|
||||
->setStatus(Credit::STATUS_SENT)
|
||||
@ -47,6 +45,7 @@ class MarkSent
|
||||
->deletePdf()
|
||||
->save();
|
||||
|
||||
event(new CreditWasMarkedSent($this->credit, $this->credit->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
return $this->credit;
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ class ApplyNumber extends AbstractService
|
||||
break;
|
||||
|
||||
default:
|
||||
// code...
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,6 @@ class ApplyPaymentAmount extends AbstractService
|
||||
$payment->service()->sendEmail();
|
||||
|
||||
/* Update Invoice balance */
|
||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
event(new InvoiceWasPaid($this->invoice, $payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
$payment->ledger()
|
||||
->updatePaymentBalance($payment->amount * -1);
|
||||
@ -104,7 +102,9 @@ class ApplyPaymentAmount extends AbstractService
|
||||
$this->invoice->service()->workFlow()->save();
|
||||
|
||||
event('eloquent.created: App\Models\Payment', $payment);
|
||||
|
||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
event(new InvoiceWasPaid($this->invoice, $payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
|
@ -175,8 +175,6 @@ class AutoBillInvoice extends AbstractService
|
||||
|
||||
}
|
||||
|
||||
event('eloquent.created: App\Models\Payment', $payment);
|
||||
|
||||
$payment->ledger()
|
||||
->updatePaymentBalance($amount * -1)
|
||||
->save();
|
||||
@ -192,7 +190,7 @@ class AutoBillInvoice extends AbstractService
|
||||
->updateCreditBalance($amount * -1, "Credit {$current_credit->number} used to pay down Invoice {$this->invoice->number}")
|
||||
->save();
|
||||
|
||||
|
||||
event('eloquent.created: App\Models\Payment', $payment);
|
||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
||||
|
||||
return $this->invoice
|
||||
|
@ -91,13 +91,6 @@ class MarkPaid extends AbstractService
|
||||
->deletePdf()
|
||||
->save();
|
||||
|
||||
// if ($this->invoice->client->getSetting('client_manual_payment_notification'))
|
||||
// $payment->service()->sendEmail();
|
||||
|
||||
/* Update Invoice balance */
|
||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
event(new InvoiceWasPaid($this->invoice, $payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
$payment->ledger()
|
||||
->updatePaymentBalance($payment->amount * -1);
|
||||
|
||||
@ -113,6 +106,10 @@ class MarkPaid extends AbstractService
|
||||
->workFlow()
|
||||
->save();
|
||||
|
||||
/* Update Invoice balance */
|
||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
event(new InvoiceWasPaid($this->invoice, $payment, $payment->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,8 @@ class UpdateInvoicePayment
|
||||
}
|
||||
|
||||
/* Need to determine here is we have an OVER payment - if YES only apply the max invoice amount */
|
||||
if($paid_amount > $invoice->partial && $paid_amount > $invoice->balance)
|
||||
$paid_amount = $invoice->balance;
|
||||
if($paid_amount > $invoice->partial && $paid_amount > $invoice->balance)
|
||||
$paid_amount = $invoice->balance;
|
||||
|
||||
/* Updates the company ledger */
|
||||
$this->payment
|
||||
@ -91,11 +91,18 @@ class UpdateInvoicePayment
|
||||
->workFlow()
|
||||
->save();
|
||||
|
||||
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
});
|
||||
|
||||
/* Remove the event updater from within the loop to prevent race conditions */
|
||||
|
||||
$this->payment->saveQuietly();
|
||||
|
||||
$invoices->each(function ($invoice) {
|
||||
|
||||
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
});
|
||||
|
||||
return $this->payment;
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +45,6 @@ class MarkSent
|
||||
$this->quote->due_date = Carbon::parse($this->quote->date)->addDays($this->quote->client->getSetting('valid_until'));
|
||||
}
|
||||
|
||||
event(new QuoteWasMarkedSent($this->quote, $this->quote->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
$this->quote
|
||||
->service()
|
||||
->setStatus(Quote::STATUS_SENT)
|
||||
@ -54,6 +52,8 @@ class MarkSent
|
||||
->deletePdf()
|
||||
->save();
|
||||
|
||||
event(new QuoteWasMarkedSent($this->quote, $this->quote->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
|
||||
return $this->quote;
|
||||
}
|
||||
}
|
||||
|
@ -110,8 +110,6 @@ class QuoteService
|
||||
$contact = $this->quote->invitations->first()->contact;
|
||||
}
|
||||
|
||||
event(new QuoteWasApproved($contact, $this->quote, $this->quote->company, Ninja::eventVars()));
|
||||
|
||||
if ($this->quote->client->getSetting('auto_convert_quote')) {
|
||||
$this->convert();
|
||||
|
||||
@ -123,6 +121,8 @@ class QuoteService
|
||||
|
||||
}
|
||||
|
||||
event(new QuoteWasApproved($contact, $this->quote, $this->quote->company, Ninja::eventVars()));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -330,17 +330,17 @@ trait MakesInvoiceValues
|
||||
// but that's no longer necessary.
|
||||
|
||||
if (isset($item->tax_rate1)) {
|
||||
$data[$key][$table_type.'.tax_rate1'] = round($item->tax_rate1, 2).'%';
|
||||
$data[$key][$table_type.'.tax_rate1'] = floatval($item->tax_rate1).'%';
|
||||
$data[$key][$table_type.'.tax1'] = &$data[$key][$table_type.'.tax_rate1'];
|
||||
}
|
||||
|
||||
if (isset($item->tax_rate2)) {
|
||||
$data[$key][$table_type.'.tax_rate2'] = round($item->tax_rate2, 2).'%';
|
||||
$data[$key][$table_type.'.tax_rate2'] = floatval($item->tax_rate2).'%';
|
||||
$data[$key][$table_type.'.tax2'] = &$data[$key][$table_type.'.tax_rate2'];
|
||||
}
|
||||
|
||||
if (isset($item->tax_rate3)) {
|
||||
$data[$key][$table_type.'.tax_rate3'] = round($item->tax_rate3, 2).'%';
|
||||
$data[$key][$table_type.'.tax_rate3'] = floatval($item->tax_rate3).'%';
|
||||
$data[$key][$table_type.'.tax3'] = &$data[$key][$table_type.'.tax_rate3'];
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,8 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
|
||||
'app_version' => '5.3.37',
|
||||
'app_tag' => '5.3.37',
|
||||
'app_version' => '5.3.38',
|
||||
'app_tag' => '5.3.38',
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', ''),
|
||||
|
74
tests/Unit/RedisVsDatabaseTest.php
Normal file
74
tests/Unit/RedisVsDatabaseTest.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Currency;
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
class RedisVsDatabaseTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp() :void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// $this->markTestSkipped('Skip test no company gateways installed');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testRedisSpeed()
|
||||
{
|
||||
$start = microtime(true);
|
||||
|
||||
$currencies = Cache::get('currencies');
|
||||
|
||||
$currencies->filter(function ($item) {
|
||||
return $item->id == 17;
|
||||
})->first();
|
||||
|
||||
nlog(microtime(true) - $start);
|
||||
|
||||
$this->assertTrue(true);
|
||||
// nlog($total_time);
|
||||
//0.0012960433959961
|
||||
}
|
||||
|
||||
|
||||
public function testDbSpeed()
|
||||
{
|
||||
$start = microtime(true);
|
||||
|
||||
$currency = Currency::find(17);
|
||||
|
||||
nlog(microtime(true) - $start);
|
||||
|
||||
$this->assertTrue(true);
|
||||
// nlog($total_time);
|
||||
// 0.006152868270874
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user