mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 03:54:36 -04:00
Static analysis cleanup
This commit is contained in:
parent
97abec29f6
commit
330492654b
@ -39,9 +39,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property int|null $gateway_type_id
|
* @property int|null $gateway_type_id
|
||||||
* @property int|null $type_id
|
* @property int|null $type_id
|
||||||
* @property int $status_id
|
* @property int $status_id
|
||||||
* @property string $amount
|
* @property float $amount
|
||||||
* @property string $refunded
|
* @property float $refunded
|
||||||
* @property string $applied
|
* @property float $applied
|
||||||
* @property string|null $date
|
* @property string|null $date
|
||||||
* @property string|null $transaction_reference
|
* @property string|null $transaction_reference
|
||||||
* @property string|null $payer_id
|
* @property string|null $payer_id
|
||||||
@ -51,7 +51,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property int|null $updated_at
|
* @property int|null $updated_at
|
||||||
* @property int|null $deleted_at
|
* @property int|null $deleted_at
|
||||||
* @property bool $is_deleted
|
* @property bool $is_deleted
|
||||||
* @property int $is_manual
|
* @property bool $is_manual
|
||||||
* @property float $exchange_rate
|
* @property float $exchange_rate
|
||||||
* @property int $currency_id
|
* @property int $currency_id
|
||||||
* @property int|null $exchange_currency_id
|
* @property int|null $exchange_currency_id
|
||||||
@ -399,66 +399,52 @@ class Payment extends BaseModel
|
|||||||
return $this->createClientDate($this->date, $this->client->timezone()->name)->format($date_format->format);
|
return $this->createClientDate($this->date, $this->client->timezone()->name)->format($date_format->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function badgeForStatus(int $status)
|
public static function badgeForStatus(int $status): string
|
||||||
{
|
{
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case self::STATUS_PENDING:
|
case self::STATUS_PENDING:
|
||||||
return '<h6><span class="badge badge-secondary">'.ctrans('texts.payment_status_1').'</span></h6>';
|
return '<h6><span class="badge badge-secondary">'.ctrans('texts.payment_status_1').'</span></h6>';
|
||||||
break;
|
|
||||||
case self::STATUS_CANCELLED:
|
case self::STATUS_CANCELLED:
|
||||||
return '<h6><span class="badge badge-warning text-white">'.ctrans('texts.payment_status_2').'</span></h6>';
|
return '<h6><span class="badge badge-warning text-white">'.ctrans('texts.payment_status_2').'</span></h6>';
|
||||||
break;
|
|
||||||
case self::STATUS_FAILED:
|
case self::STATUS_FAILED:
|
||||||
return '<h6><span class="badge badge-danger">'.ctrans('texts.payment_status_3').'</span></h6>';
|
return '<h6><span class="badge badge-danger">'.ctrans('texts.payment_status_3').'</span></h6>';
|
||||||
break;
|
|
||||||
case self::STATUS_COMPLETED:
|
case self::STATUS_COMPLETED:
|
||||||
return '<h6><span class="badge badge-info">'.ctrans('texts.payment_status_4').'</span></h6>';
|
return '<h6><span class="badge badge-info">'.ctrans('texts.payment_status_4').'</span></h6>';
|
||||||
break;
|
|
||||||
case self::STATUS_PARTIALLY_REFUNDED:
|
case self::STATUS_PARTIALLY_REFUNDED:
|
||||||
return '<h6><span class="badge badge-success">'.ctrans('texts.payment_status_5').'</span></h6>';
|
return '<h6><span class="badge badge-success">'.ctrans('texts.payment_status_5').'</span></h6>';
|
||||||
break;
|
|
||||||
case self::STATUS_REFUNDED:
|
case self::STATUS_REFUNDED:
|
||||||
return '<h6><span class="badge badge-primary">'.ctrans('texts.payment_status_6').'</span></h6>';
|
return '<h6><span class="badge badge-primary">'.ctrans('texts.payment_status_6').'</span></h6>';
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// code...
|
return '';
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function stringStatus(int $status)
|
public static function stringStatus(int $status): string
|
||||||
{
|
{
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case self::STATUS_PENDING:
|
case self::STATUS_PENDING:
|
||||||
return ctrans('texts.payment_status_1');
|
return ctrans('texts.payment_status_1');
|
||||||
break;
|
|
||||||
case self::STATUS_CANCELLED:
|
case self::STATUS_CANCELLED:
|
||||||
return ctrans('texts.payment_status_2');
|
return ctrans('texts.payment_status_2');
|
||||||
break;
|
|
||||||
case self::STATUS_FAILED:
|
case self::STATUS_FAILED:
|
||||||
return ctrans('texts.payment_status_3');
|
return ctrans('texts.payment_status_3');
|
||||||
break;
|
|
||||||
case self::STATUS_COMPLETED:
|
case self::STATUS_COMPLETED:
|
||||||
return ctrans('texts.payment_status_4');
|
return ctrans('texts.payment_status_4');
|
||||||
break;
|
|
||||||
case self::STATUS_PARTIALLY_REFUNDED:
|
case self::STATUS_PARTIALLY_REFUNDED:
|
||||||
return ctrans('texts.payment_status_5');
|
return ctrans('texts.payment_status_5');
|
||||||
break;
|
|
||||||
case self::STATUS_REFUNDED:
|
case self::STATUS_REFUNDED:
|
||||||
return ctrans('texts.payment_status_6');
|
return ctrans('texts.payment_status_6');
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ledger()
|
public function ledger(): LedgerService
|
||||||
{
|
{
|
||||||
return new LedgerService($this);
|
return new LedgerService($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function service()
|
public function service(): PaymentService
|
||||||
{
|
{
|
||||||
return new PaymentService($this);
|
return new PaymentService($this);
|
||||||
}
|
}
|
||||||
@ -469,7 +455,7 @@ class Payment extends BaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getCompletedAmount() :float
|
public function getCompletedAmount() :float
|
||||||
{
|
{
|
||||||
@ -563,7 +549,7 @@ class Payment extends BaseModel
|
|||||||
'payment_refunded' => $payment->refunded ?: 0,
|
'payment_refunded' => $payment->refunded ?: 0,
|
||||||
'payment_status' => $payment->status_id ?: 1,
|
'payment_status' => $payment->status_id ?: 1,
|
||||||
'paymentables' => $payment->paymentables->toArray(),
|
'paymentables' => $payment->paymentables->toArray(),
|
||||||
'payment_request' => request() ? request()->all() : [],
|
'payment_request' => [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property int $id
|
* @property int $id
|
||||||
* @property int $payment_id
|
* @property int $payment_id
|
||||||
* @property int $paymentable_id
|
* @property int $paymentable_id
|
||||||
* @property string $amount
|
* @property float $amount
|
||||||
* @property string $refunded
|
* @property float $refunded
|
||||||
* @property string $paymentable_type
|
* @property string $paymentable_type
|
||||||
* @property int|null $created_at
|
* @property int|null $created_at
|
||||||
* @property int|null $updated_at
|
* @property int|null $updated_at
|
||||||
@ -51,13 +51,6 @@ class Paymentable extends Pivot
|
|||||||
|
|
||||||
protected $table = 'paymentables';
|
protected $table = 'paymentables';
|
||||||
|
|
||||||
//protected $dateFormat = 'Y-m-d H:i:s.u';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that should be cast to native types.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'updated_at' => 'timestamp',
|
'updated_at' => 'timestamp',
|
||||||
'created_at' => 'timestamp',
|
'created_at' => 'timestamp',
|
||||||
|
@ -146,7 +146,7 @@ class FacturaEInvoice extends AbstractService
|
|||||||
|
|
||||||
private function setPoNumber(): self
|
private function setPoNumber(): self
|
||||||
{
|
{
|
||||||
if(strlen($this->invoice->po_number > 1)) {
|
if(strlen($this->invoice->po_number) > 1) {
|
||||||
$this->fac->setReferences($this->invoice->po_number);
|
$this->fac->setReferences($this->invoice->po_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,17 +16,9 @@ use App\Services\AbstractService;
|
|||||||
|
|
||||||
class UpdateBalance extends AbstractService
|
class UpdateBalance extends AbstractService
|
||||||
{
|
{
|
||||||
public $invoice;
|
|
||||||
|
|
||||||
public $balance_adjustment;
|
public function __construct(public Invoice $invoice, public float $balance_adjustment, public bool $is_draft)
|
||||||
|
|
||||||
private $is_draft;
|
|
||||||
|
|
||||||
public function __construct($invoice, $balance_adjustment, bool $is_draft)
|
|
||||||
{
|
{
|
||||||
$this->invoice = $invoice;
|
|
||||||
$this->balance_adjustment = $balance_adjustment;
|
|
||||||
$this->is_draft = $is_draft;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
@ -35,20 +27,12 @@ class UpdateBalance extends AbstractService
|
|||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlog("invoice id = {$this->invoice->id}");
|
|
||||||
nlog("invoice balance = {$this->invoice->balance}");
|
|
||||||
nlog("invoice adjustment = {$this->balance_adjustment}");
|
|
||||||
|
|
||||||
// $this->invoice->balance += floatval($this->balance_adjustment);
|
|
||||||
|
|
||||||
$this->invoice->increment('balance', floatval($this->balance_adjustment));
|
$this->invoice->increment('balance', floatval($this->balance_adjustment));
|
||||||
|
|
||||||
if ($this->invoice->balance == 0 && ! $this->is_draft) {
|
if ($this->invoice->balance == 0 && ! $this->is_draft) {
|
||||||
$this->invoice->status_id = Invoice::STATUS_PAID;
|
$this->invoice->status_id = Invoice::STATUS_PAID;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlog("final balance = {$this->invoice->balance}");
|
|
||||||
|
|
||||||
return $this->invoice;
|
return $this->invoice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user