mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Working on reminders
This commit is contained in:
parent
697fa568db
commit
d598aeeb03
52
app/Console/Commands/SendRemindersCron.php
Normal file
52
app/Console/Commands/SendRemindersCron.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\Ninja\SendReminders;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendRemindersCron extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'ninja:send-reminders';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Force send all reminders';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
SendReminders::dispatchNow();
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ class CompanySettings extends BaseSettings
|
||||
public $enable_client_portal = true; //@implemented
|
||||
public $enable_client_portal_dashboard = true; // @TODO There currently is no dashboard so this is pending
|
||||
public $signature_on_pdf = false; //@implemented
|
||||
public $document_email_attachment = false;
|
||||
public $document_email_attachment = false; //@TODO I assume this is 3rd party attachments on the entity to be included
|
||||
|
||||
public $portal_design_id = '1'; //?@deprecated
|
||||
|
||||
@ -119,16 +119,16 @@ class CompanySettings extends BaseSettings
|
||||
|
||||
//public $design = 'views/pdf/design1.blade.php'; //@deprecated - never used
|
||||
|
||||
public $invoice_terms = '';
|
||||
public $invoice_terms = ''; //@implemented
|
||||
public $quote_terms = ''; //@implemented
|
||||
public $invoice_taxes = 0; // ? used in AP only?
|
||||
// public $enabled_item_tax_rates = 0;
|
||||
public $invoice_design_id = 'VolejRejNm'; //@implemented
|
||||
public $quote_design_id = 'VolejRejNm'; //@implemented
|
||||
public $credit_design_id = 'VolejRejNm'; //@implemented
|
||||
public $invoice_footer = '';
|
||||
public $credit_footer = '';
|
||||
public $credit_terms = '';
|
||||
public $invoice_footer = ''; //@implemented
|
||||
public $credit_footer = ''; //@implemented
|
||||
public $credit_terms = ''; //@implemented
|
||||
public $invoice_labels = ''; //@TODO used in AP only?
|
||||
public $tax_name1 = ''; //@TODO where do we use this?
|
||||
public $tax_rate1 = 0; //@TODO where do we use this?
|
||||
|
@ -16,7 +16,6 @@ use App\Http\Requests\Credit\ShowCreditRequest;
|
||||
use App\Http\Requests\Credit\StoreCreditRequest;
|
||||
use App\Http\Requests\Credit\UpdateCreditRequest;
|
||||
use App\Http\Requests\Invoice\EditInvoiceRequest;
|
||||
use App\Jobs\Credit\StoreCredit;
|
||||
use App\Jobs\Entity\EmailEntity;
|
||||
use App\Jobs\Invoice\EmailCredit;
|
||||
use App\Jobs\Invoice\MarkInvoicePaid;
|
||||
@ -188,7 +187,9 @@ class CreditController extends BaseController
|
||||
|
||||
$credit = $this->credit_repository->save($request->all(), CreditFactory::create(auth()->user()->company()->id, auth()->user()->id));
|
||||
|
||||
$credit = StoreCredit::dispatchNow($credit, $request->all(), $credit->company);
|
||||
$credit = $credit->service()
|
||||
->fillDefaults()
|
||||
->save();
|
||||
|
||||
event(new CreditWasCreated($credit, $credit->company, Ninja::eventVars()));
|
||||
|
||||
|
@ -213,7 +213,10 @@ class InvoiceController extends BaseController
|
||||
|
||||
event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars()));
|
||||
|
||||
$invoice = $invoice->service()->triggeredActions($request)->save();
|
||||
$invoice = $invoice->service()
|
||||
->fillDefaults()
|
||||
->triggeredActions($request)
|
||||
->save();
|
||||
|
||||
return $this->itemResponse($invoice);
|
||||
}
|
||||
|
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Credit;
|
||||
|
||||
use App\Jobs\Payment\PaymentNotification;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Company;
|
||||
use App\Models\Credit;
|
||||
use App\Repositories\CreditRepository;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class StoreCredit implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $credit;
|
||||
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Credit $credit
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(Credit $credit, array $data)
|
||||
{
|
||||
$this->credit = $credit;
|
||||
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param CreditRepository $credit_repository
|
||||
* @return Credit|null
|
||||
*/
|
||||
public function handle(CreditRepository $credit_repository): ?Credit
|
||||
{
|
||||
// MultiDB::setDB($this->company->db);
|
||||
|
||||
// $payment = false;
|
||||
|
||||
// if ($payment) {
|
||||
// PaymentNotification::dispatch($payment, $payment->company);
|
||||
// }
|
||||
|
||||
return $this->credit;
|
||||
}
|
||||
}
|
60
app/Jobs/Ninja/SendReminders.php
Normal file
60
app/Jobs/Ninja/SendReminders.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Jobs\Ninja;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SendReminders implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
info("Sending reminders ".Carbon::now()->format('Y-m-d h:i:s'));
|
||||
|
||||
if (! config('ninja.db.multi_db_enabled')) {
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
//multiDB environment, need to
|
||||
foreach (MultiDB::$dbs as $db) {
|
||||
|
||||
MultiDB::setDB($db);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -104,6 +104,17 @@ class CreditService
|
||||
|
||||
public function fillDefaults()
|
||||
{
|
||||
$settings = $this->credit->client->getMergedSettings();
|
||||
|
||||
if(! $this->credit->design_id)
|
||||
$this->credit->design_id = $this->decodePrimaryKey($settings->credit_design_id);
|
||||
|
||||
if(!isset($this->credit->footer))
|
||||
$this->credit->footer = $settings->credit_footer;
|
||||
|
||||
if(!isset($this->credit->terms))
|
||||
$this->credit->terms = $settings->credit_terms;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ class AutoBillInvoice extends AbstractService
|
||||
if($this->client->getSetting('use_credits_payment') != 'off')
|
||||
$this->applyCreditPayment();
|
||||
|
||||
info("partial = {$this->invoice->partial}");
|
||||
info("balance = {$this->invoice->balance}");
|
||||
// info("partial = {$this->invoice->partial}");
|
||||
// info("balance = {$this->invoice->balance}");
|
||||
|
||||
/* Determine $amount */
|
||||
if ($this->invoice->partial > 0)
|
||||
|
@ -365,6 +365,17 @@ class InvoiceService
|
||||
|
||||
public function fillDefaults()
|
||||
{
|
||||
$settings = $this->invoice->client->getMergedSettings();
|
||||
|
||||
if(! $this->invoice->design_id)
|
||||
$this->invoice->design_id = $this->decodePrimaryKey($settings->invoice_design_id);
|
||||
|
||||
if(!isset($this->invoice->footer))
|
||||
$this->invoice->footer = $settings->invoice_footer;
|
||||
|
||||
if(!isset($this->invoice->terms))
|
||||
$this->invoice->terms = $settings->invoice_terms;
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user