Removed redundant functions in Account, Optimised User a little more, Moved Ezypay Commands to new Ezypay folder

This commit is contained in:
2024-07-07 10:21:27 +10:00
parent 70e94bf6e6
commit b4f3db04fc
11 changed files with 91 additions and 85 deletions

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Ezypay;
use Carbon\Carbon;
use Illuminate\Console\Command;
@@ -8,14 +8,14 @@ use Illuminate\Console\Command;
use App\Classes\External\Payments\Ezypay;
use App\Models\Account;
class PaymentsEzypayNext extends Command
class PaymentNext extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'payments:ezypay:next';
protected $signature = 'ezypay:payment:next';
/**
* The console command description.
@@ -35,14 +35,12 @@ class PaymentsEzypayNext extends Command
foreach ($poo->getCustomers() as $c) {
if ($c->BillingStatus == 'Inactive') {
$this->info(sprintf('Ignoring INACTIVE: [%s] %s %s',$c->EzypayReferenceNumber,$c->Firstname,$c->Surname));
$this->comment(sprintf('Ignoring INACTIVE: [%s] %s %s',$c->EzypayReferenceNumber,$c->Firstname,$c->Surname));
continue;
}
// Load Account Details from ReferenceId
$ao = Account::where('site_id',(int)substr($c->ReferenceId,0,2))
->where('id',(int)substr($c->ReferenceId,2,4))
->single();
$ao = Account::find((int)substr($c->ReferenceId,2,4));
if (! $ao) {
$this->warn(sprintf('Missing: [%s] %s %s (%s)',$c->EzypayReferenceNumber,$c->Firstname,$c->Surname,$c->ReferenceId));
@@ -50,7 +48,14 @@ class PaymentsEzypayNext extends Command
}
// Get Due Invoices
$account_due = $ao->dueInvoices()->sum('due');
$invoice_due = $ao->invoiceSummaryDue()->get();
$this->info(sprintf('Account [%s] (%s) has [%d] invoices due, totalling [%3.2f]',
$ao->lid,
$ao->name,
$invoice_due->count(),
($due=$invoice_due->sum('_balance')),
));
$next_pay = $poo->getDebits([
'customerId'=>$c->Id,
@@ -59,32 +64,32 @@ class PaymentsEzypayNext extends Command
])->reverse()->first();
if ($next_pay->Status !== 'Pending') {
$this->warn(sprintf('Next payment is not pending for (%s)',$ao->name));
$this->warn(sprintf('- Next payment is not pending for (%s)',$ao->name));
continue;
}
$next_paydate = Carbon::createFromTimeString($next_pay->Date);
if ($next_pay->Amount < $account_due)
$this->warn(sprintf('Next payment on [%s] for (%s) [%s] not sufficient for outstanding balance [%s]',
if ($next_pay->Amount < $due)
$this->error(sprintf('- Next payment on [%s] for (%s) [%s] not sufficient for outstanding balance [%s]',
$next_paydate->format('Y-m-d'),
$ao->name,
number_format($next_pay->Amount,2),
number_format($account_due,2)));
number_format($due,2)));
elseif ($next_pay->Amount > $account_due)
$this->warn(sprintf('Next payment on [%s] for (%s) [%s] is too much for outstanding balance [%s]',
elseif ($next_pay->Amount > $due)
$this->warn(sprintf('- Next payment on [%s] for (%s) [%s] is too much for outstanding balance [%s]',
$next_paydate->format('Y-m-d'),
$ao->name,
number_format($next_pay->Amount,2),
number_format($account_due,2)));
number_format($due,2)));
else
$this->info(sprintf('Next payment on [%s] for (%s) [%s] will cover outstanding balance [%s]',
$this->info(sprintf('- Next payment on [%s] for (%s) [%s] will cover outstanding balance [%s]',
$next_paydate->format('Y-m-d'),
$ao->name,
number_format($next_pay->Amount,2),
number_format($account_due,2)));
number_format($due,2)));
}
}
}

View File

@@ -1,20 +1,20 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Ezypay;
use Illuminate\Console\Command;
use App\Classes\External\Payments\Ezypay;
use App\Jobs\PaymentsImport as Job;
class PaymentsEzypayImport extends Command
class PaymentsImport extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'payments:ezypay:import';
protected $signature = 'ezypay:payment:import';
/**
* The console command description.