Separated Checkout and Payment controllers, updates to checkout and payments

This commit is contained in:
2024-08-10 10:14:47 +10:00
parent 06f25d5d4d
commit efbb3d091f
23 changed files with 512 additions and 603 deletions

View File

@@ -6,9 +6,11 @@ use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Leenooks\Traits\ScopeActive;
use App\Traits\SiteID;
class Checkout extends Model
{
use ScopeActive;
use ScopeActive,SiteID;
protected $casts = [
'plugin_data'=>'json',

View File

@@ -300,8 +300,7 @@ class Invoice extends Model implements IDs
/**
* @param \Leenooks\Carbon $start Start Date
* @param Carbon $end End Date
* @param int $interval Period End Date
* @param bool $strict
* @param Collection $period
* @return float
* @throws \Exception
*/
@@ -373,7 +372,7 @@ class Invoice extends Model implements IDs
public function payments()
{
return $this->hasManyThrough(Payment::class,PaymentItem::class,NULL,'id',NULL,'payment_id')
->where('active',TRUE);
->where('payments.active',TRUE);
}
/**

View File

@@ -7,8 +7,7 @@ use Illuminate\Support\Facades\DB;
use Leenooks\Traits\ScopeActive;
use App\Interfaces\IDs;
use App\Traits\ProviderRef;
use App\Traits\PushNew;
use App\Traits\{ProviderRef,PushNew,SiteID};
/**
* Class Payment
@@ -25,7 +24,7 @@ use App\Traits\PushNew;
*/
class Payment extends Model implements IDs
{
use PushNew,ScopeActive,ProviderRef;
use PushNew,ScopeActive,ProviderRef,SiteID;
protected $casts = [
'paid_at'=>'datetime:Y-m-d',
@@ -106,7 +105,7 @@ class Payment extends Model implements IDs
->select(['payments.id','paid_at','account_id','checkout_id','total_amt',DB::raw("SUM(ABS(amount)) as allocated")])
->leftJoin('payment_items',['payment_items.payment_id'=>'payments.id'])
->groupBy(['payments.id','paid_at','total_amt','account_id','checkout_id'])
->having(DB::raw('ROUND(total_amt-IFNULL(allocated,0),2)'),'>',self::threshold);
->having(DB::raw('ROUND(CAST(total_amt-COALESCE(SUM(ABS(amount)),0) AS NUMERIC),2)'),'>',self::threshold);
}
/* ATTRIBUTES */