Added list option to invoice:generate. Fix account PushNew()

This commit is contained in:
Deon George 2020-05-29 14:40:49 +10:00
parent 121aa5b31c
commit 251298a230
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
2 changed files with 22 additions and 3 deletions

View File

@ -14,7 +14,7 @@ class InvoiceGenerate extends Command
*
* @var string
*/
protected $signature = 'invoice:generate {account?} {--p|preview : Preview}';
protected $signature = 'invoice:generate {account?} {--p|preview : Preview} {--l|list : List Items}';
/**
* The console command description.
@ -60,6 +60,24 @@ class InvoiceGenerate extends Command
$io->account_id = $o->id;
if ($this->option('list')) {
$this->warn(sprintf('|%4s|%4s|%-50s|%8s|',
'SID',
'PID',
'Name',
'Amount',
));
foreach ($io->items as $oo) {
$this->info(sprintf('|%4s|%4s|%-50s|%8.2f|',
$oo->service_id,
$oo->product_id,
$oo->item_type_name,
$oo->total,
));
}
}
if ($this->option('preview')) {
$this->info(sprintf('Invoice for Account [%d] - [%d] items totalling [%3.2f]',$o->id,$io->items->count(),$io->total));
continue;

View File

@ -6,10 +6,11 @@ use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use App\Traits\NextKey;
use App\Traits\PushNew;
class Account extends Model
{
use NextKey;
use NextKey,PushNew;
const RECORD_ID = 'account';
public $incrementing = FALSE;
@ -92,7 +93,7 @@ class Account extends Model
// Build our where clause
// First Name, Last name
if (preg_match('/\ /',$term)) {
list($fn,$ln) = explode(' ',$term,2);
[$fn,$ln] = explode(' ',$term,2);
$query->where(function($query1) use ($fn,$ln,$term) {
$query1->where(function($query2) use ($fn,$ln) {