'decimal:2', 'tax' => 'decimal:2', 'total' => 'decimal:2', 'discount_refund' => 'decimal:2', 'created_at' => 'datetime', ]; /** * Relación con la venta original */ public function sale() { return $this->belongsTo(Sale::class); } /** * Relación con usuario que procesó la devolución */ public function user() { return $this->belongsTo(User::class); } /** * Relación con caja registradora */ public function cashRegister() { return $this->belongsTo(CashRegister::class); } /** * Detalles de la devolución */ public function details() { return $this->hasMany(ReturnDetail::class, 'return_id'); } /** * Obtener texto descriptivo de la razón */ public function getReasonTextAttribute(): string { return match($this->reason) { 'defective' => 'Producto defectuoso', 'wrong_product' => 'Producto incorrecto', 'change_of_mind' => 'Cambio de opinión', 'damaged' => 'Producto dañado', 'other' => 'Otra razón', default => 'No especificado', }; } }