diff --git a/app/Models/Payment.php b/app/Models/Payment.php index ff40d6c8dbbf..27cd529483ac 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -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 '
'.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: - // 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' => [], ]; } diff --git a/app/Models/Paymentable.php b/app/Models/Paymentable.php index 81aaf23fb413..c8112f826c0b 100644 --- a/app/Models/Paymentable.php +++ b/app/Models/Paymentable.php @@ -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', diff --git a/app/Services/Invoice/EInvoice/FacturaEInvoice.php b/app/Services/Invoice/EInvoice/FacturaEInvoice.php index 7505956c74ab..b2255bc9959d 100644 --- a/app/Services/Invoice/EInvoice/FacturaEInvoice.php +++ b/app/Services/Invoice/EInvoice/FacturaEInvoice.php @@ -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); } diff --git a/app/Services/Invoice/UpdateBalance.php b/app/Services/Invoice/UpdateBalance.php index 9b9faef66efe..a998dc955fd3 100644 --- a/app/Services/Invoice/UpdateBalance.php +++ b/app/Services/Invoice/UpdateBalance.php @@ -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; } }