Temporarily fix invoice emailing
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 35s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s

This commit is contained in:
Deon George 2024-07-06 10:28:45 +10:00
parent 693f247865
commit d662328903
8 changed files with 94 additions and 53 deletions

View File

@ -27,7 +27,7 @@ REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_MAILER=smtp
MAIL_HOST=smtp
MAIL_PORT=25
MAIL_USERNAME=null

View File

@ -35,15 +35,17 @@ class InvoiceEmail extends Command
$o = Invoice::findOrFail($this->argument('id'));
Mail::to($o->account->user->email)->send(new \App\Mail\InvoiceEmail($o));
$result = Mail::to($o->account->user->email)->send(new \App\Mail\InvoiceEmail($o));
try {
$o->print_status = TRUE;
$o->reminders = $o->reminders('send');
//$o->reminders = $o->reminders('send');
$o->save();
} catch (\Exception $e) {
dd($e);
}
dump($result->getDebug());
}
}

View File

@ -1,46 +0,0 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Jobs\BroadbandTraffic;
use App\Models\Supplier;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// @todo This needs to be more generic and dynamic
// Exetel Traffic
$schedule->job(new BroadbandTraffic(Supplier::find(1)))->timezone('Australia/Melbourne')->dailyAt('10:00');
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers;
use Clarkeash\Doorman\Exceptions\{ExpiredInviteCode,InvalidInviteCode,NotYourInviteCode};
use Clarkeash\Doorman\Facades\Doorman;
use Illuminate\View\View;
use Barryvdh\Snappy\Facades\SnappyPdf as PDF;
@ -33,10 +35,20 @@ class InvoiceController extends Controller
* Render a specific invoice for the user
*
* @param Invoice $o
* @param string|null $code
* @return View
*/
public function view(Invoice $o): View
public function view(Invoice $o,string $code=NULL): View
{
if ($code) {
try {
Doorman::redeem($code,$o->account->user->email);
} catch (ExpiredInviteCode|InvalidInviteCode|NotYourInviteCode $e) {
abort(404);
}
}
return view('theme.backend.adminlte.invoice.view')
->with('o',$o);
}

View File

@ -2,6 +2,7 @@
namespace App\Mail;
use App\Models\Site;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
@ -15,6 +16,7 @@ class InvoiceEmail extends Mailable
use Queueable, SerializesModels;
public $invoice;
public $site;
/**
* Create a new message instance.
@ -33,10 +35,11 @@ class InvoiceEmail extends Mailable
*/
public function build()
{
Config::set('site',$this->invoice->site);
Config::set('site',Site::findOrFail($this->invoice->site_id));
$this->site = config('site');
return $this
->markdown('email.user.invoice')
->markdown('email.user.invoice',['site'=>config('site')])
->subject(sprintf( 'Invoice: %s - Total: $%s - Due: %s',
$this->invoice->id,
number_format($this->invoice->total,2),

View File

@ -132,7 +132,7 @@ class Product extends Model implements IDs
return $this->hasOne(ProductTranslate::class)
->where('language_id',(Auth::user() && Auth::user()->language_id)
? Auth::user()->language_id
: config('site')->language_id);
: config('osb.language_id'));
}
/**

65
config/doorman.php Normal file
View File

@ -0,0 +1,65 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Invite Table Name
|--------------------------------------------------------------------------
|
*/
'invite_table_name' => 'invites',
/*
|--------------------------------------------------------------------------
| Invite Model Class
|--------------------------------------------------------------------------
|
| This option allows you to override the default model.
| Your model MUST extend the base Invite model.
|
| Default: Clarkeash\Doorman\Models\Invite::class
*/
'invite_model' => Clarkeash\Doorman\Models\Invite::class,
/*
|--------------------------------------------------------------------------
| Default Code Generator
|--------------------------------------------------------------------------
|
| This option controls how the invite codes are generated.
| You should adjust this based on your needs.
|
| Supported: "basic", "uuid"
|
*/
'driver' => env('DOORMAN_DRIVER', 'basic'),
/*
|--------------------------------------------------------------------------
| Driver Configurations
|--------------------------------------------------------------------------
|
| Here are each of the driver configurations for your application.
| You can customize should your application require it.
|
*/
'basic' => [
'length' => 6,
],
/*
|--------------------------------------------------------------------------
| UUID
|--------------------------------------------------------------------------
|
| supported versions: 1,3,4,5
|
| Versions 3 & 5, require 'namespace' and 'name' to be set
|
*/
'uuid' => [
'version' => 4,
],
];

5
config/osb.php Normal file
View File

@ -0,0 +1,5 @@
<?php
return [
'language_id' => 1,
];