mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01: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 $type_id
|
||||
* @property int $status_id
|
||||
* @property string $amount
|
||||
* @property string $refunded
|
||||
* @property string $applied
|
||||
* @property float $amount
|
||||
* @property float $refunded
|
||||
* @property float $applied
|
||||
* @property string|null $date
|
||||
* @property string|null $transaction_reference
|
||||
* @property string|null $payer_id
|
||||
@ -51,7 +51,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @property int|null $updated_at
|
||||
* @property int|null $deleted_at
|
||||
* @property bool $is_deleted
|
||||
* @property int $is_manual
|
||||
* @property bool $is_manual
|
||||
* @property float $exchange_rate
|
||||
* @property int $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);
|
||||
}
|
||||
|
||||
public static function badgeForStatus(int $status)
|
||||
public static function badgeForStatus(int $status): string
|
||||
{
|
||||
switch ($status) {
|
||||
case self::STATUS_PENDING:
|
||||
return '<h6><span class="badge badge-secondary">'.ctrans('texts.payment_status_1').'</span></h6>';
|
||||
break;
|
||||
case self::STATUS_CANCELLED:
|
||||
return '<h6><span class="badge badge-warning text-white">'.ctrans('texts.payment_status_2').'</span></h6>';
|
||||
break;
|
||||
case self::STATUS_FAILED:
|
||||
return '<h6><span class="badge badge-danger">'.ctrans('texts.payment_status_3').'</span></h6>';
|
||||
break;
|
||||
case self::STATUS_COMPLETED:
|
||||
return '<h6><span class="badge badge-info">'.ctrans('texts.payment_status_4').'</span></h6>';
|
||||
break;
|
||||
case self::STATUS_PARTIALLY_REFUNDED:
|
||||
return '<h6><span class="badge badge-success">'.ctrans('texts.payment_status_5').'</span></h6>';
|
||||
break;
|
||||
case self::STATUS_REFUNDED:
|
||||
return '<h6><span class="badge badge-primary">'.ctrans('texts.payment_status_6').'</span></h6>';
|
||||
break;
|
||||
default:
|
||||
// code...
|
||||
break;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
public static function stringStatus(int $status)
|
||||
public static function stringStatus(int $status): string
|
||||
{
|
||||
switch ($status) {
|
||||
case self::STATUS_PENDING:
|
||||
return ctrans('texts.payment_status_1');
|
||||
break;
|
||||
case self::STATUS_CANCELLED:
|
||||
return ctrans('texts.payment_status_2');
|
||||
break;
|
||||
case self::STATUS_FAILED:
|
||||
return ctrans('texts.payment_status_3');
|
||||
break;
|
||||
case self::STATUS_COMPLETED:
|
||||
return ctrans('texts.payment_status_4');
|
||||
break;
|
||||
case self::STATUS_PARTIALLY_REFUNDED:
|
||||
return ctrans('texts.payment_status_5');
|
||||
break;
|
||||
case self::STATUS_REFUNDED:
|
||||
return ctrans('texts.payment_status_6');
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function ledger()
|
||||
public function ledger(): LedgerService
|
||||
{
|
||||
return new LedgerService($this);
|
||||
}
|
||||
|
||||
public function service()
|
||||
public function service(): PaymentService
|
||||
{
|
||||
return new PaymentService($this);
|
||||
}
|
||||
@ -469,7 +455,7 @@ class Payment extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @return float
|
||||
*/
|
||||
public function getCompletedAmount() :float
|
||||
{
|
||||
@ -563,7 +549,7 @@ class Payment extends BaseModel
|
||||
'payment_refunded' => $payment->refunded ?: 0,
|
||||
'payment_status' => $payment->status_id ?: 1,
|
||||
'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 $payment_id
|
||||
* @property int $paymentable_id
|
||||
* @property string $amount
|
||||
* @property string $refunded
|
||||
* @property float $amount
|
||||
* @property float $refunded
|
||||
* @property string $paymentable_type
|
||||
* @property int|null $created_at
|
||||
* @property int|null $updated_at
|
||||
@ -51,13 +51,6 @@ class Paymentable extends Pivot
|
||||
|
||||
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 = [
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
|
@ -146,7 +146,7 @@ class FacturaEInvoice extends AbstractService
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -16,17 +16,9 @@ use App\Services\AbstractService;
|
||||
|
||||
class UpdateBalance extends AbstractService
|
||||
{
|
||||
public $invoice;
|
||||
|
||||
public $balance_adjustment;
|
||||
|
||||
private $is_draft;
|
||||
|
||||
public function __construct($invoice, $balance_adjustment, bool $is_draft)
|
||||
public function __construct(public Invoice $invoice, public float $balance_adjustment, public bool $is_draft)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
$this->balance_adjustment = $balance_adjustment;
|
||||
$this->is_draft = $is_draft;
|
||||
}
|
||||
|
||||
public function run()
|
||||
@ -35,20 +27,12 @@ class UpdateBalance extends AbstractService
|
||||
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));
|
||||
|
||||
if ($this->invoice->balance == 0 && ! $this->is_draft) {
|
||||
$this->invoice->status_id = Invoice::STATUS_PAID;
|
||||
}
|
||||
|
||||
nlog("final balance = {$this->invoice->balance}");
|
||||
|
||||
return $this->invoice;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user