Asiento
extends ModelClass
in package
uses
ModelTrait, ExerciseRelationTrait
The accounting entry. It is related to an exercise and consists of games.
Table of Contents
Constants
- OPERATION_CLOSING = 'C'
- OPERATION_GENERAL = null
- OPERATION_OPENING = 'A'
- OPERATION_REGULARIZATION = 'R'
- RENUMBER_LIMIT = 1000
Properties
- $canal : int
- Accounting channel. For statistics purpose.
- $codejercicio : string
- Exercise code.
- $concepto : string
- Accounting entry concept.
- $debe : float
- $documento : string
- Document associated with the accounting entry.
- $editable : bool
- True if it is editable, but false.
- $fecha : string
- Date of the accounting entry.
- $haber : float
- $idasiento : int
- Primary key.
- $iddiario : int
- Diary identifier.
- $idempresa : int
- Foreign Key with Empresas table.
- $importe : float|int
- Amount of the accounting entry.
- $numero : string
- Accounting entry number. It will be modified when renumbering.
- $operacion : string
- It establishes whether the accounting entry is of a special operation: - opening - regularization - closing
- $attributes : array<string|int, mixed>
- The model's attributes.
- $dataBase : DataBase
- It provides direct access to the database.
- $fields : array<string|int, mixed>
- List of fields in the table.
- $original : array<string|int, mixed>
- The model's original attributes.
Methods
- __construct() : mixed
- __get() : mixed
- __isset() : bool
- __set() : void
- __unset() : void
- accumulateAmounts() : mixed
- Accumulate the amounts of the detail in the document
- addExtension() : void
- all() : array<string|int, static>
- Devuelve todos los registros que cumplen las condiciones.
- changeId() : bool
- changePrimaryColumnValue() : bool
- clear() : void
- clearCache() : void
- count() : int
- create() : static|null
- delete() : bool
- deleteWhere() : bool
- editable() : bool
- exists() : bool
- find() : static|null
- findOrCreate() : static|null
- findWhere() : static|null
- findWhereEq() : static|null
- get() : mixed
- getApiFieldsToHide() : array<string|int, string>
- Devuelve los nombres de campos que no deben exponerse en la API (ni en GET, ni en el schema). Los modelos con datos sensibles deben sobrescribir este método.
- getDirty() : array<string|int, mixed>
- Devuelve un array asociativo con los campos modificados y sus valores actuales.
- getExercise() : Ejercicio
- getLines() : array<string|int, Partida>
- getModelFields() : array<string|int, mixed>
- Returns the list of fields in the table.
- getNewLine() : Partida
- getOriginal() : mixed|null
- Devuelve el valor original de un campo, si no se indica campo devuelve todo el array original
- hasChanged() : bool
- hasColumn() : bool
- hasExtension() : bool
- id() : mixed
- initTotals() : mixed
- Initializes the total fields
- install() : string
- isBalanced() : bool
- Returns TRUE if accounting entry is balanced.
- isDirty() : bool
- Comprueba si los campos del modelo han sido modificados.
- load() : bool
- Carga un modelo dada su primary key
- loadFromCode() : bool
- Carga un registro del modelo utilizando un código y opcionalmente condiciones adicionales.
- loadFromData() : void
- loadWhere() : bool
- Carga el primer registro que coincida con las condiciones especificadas.
- loadWhereEq() : bool
- modelClassName() : string
- Returns the name of the class of the model.
- newCode() : int
- Returns the following code for the reported field or the primary key of the model.
- pipe() : mixed
- pipeFalse() : bool
- primaryColumn() : string
- primaryColumnValue() : mixed
- primaryDescription() : mixed
- primaryDescriptionColumn() : string
- reload() : bool
- renumber() : bool
- Renumber the accounting entries of the given exercise.
- save() : bool
- Guarda el modelo en la base de datos después de ejecutar las comprobaciones `$this->test()`
- setDate() : bool
- syncOriginal() : void
- table() : DbQuery
- tableName() : string
- test() : bool
- Realiza pruebas de validación sobre los campos del modelo antes de guardarlo.
- toArray() : array<string|int, mixed>
- Devuelve un array con los campos y valores del modelo.
- totalSum() : float
- update() : bool
- Actualiza el modelo con los valores proporcionados en el array
- updateOrCreate() : static|null
- url() : string
- Genera una URL para el modelo según el tipo especificado.
- belongsTo() : object|null
- Define una relación uno a uno.
- db() : DataBase
- hasMany() : array<string|int, mixed>
- Define a one-to-many relationship.
- loadModelFields() : void
- onChange() : bool
- Este método se llama antes de guardar (insertar) un nuevo registro en la base de datos.
- onDelete() : void
- Este método se llama al eliminar un registro de la base de datos.
- onInsert() : void
- Este método se llama al insertar un nuevo registro en la base de datos (saveInsert).
- onUpdate() : void
- Este método se llama al insertar un nuevo registro en la base de datos (saveUpdate).
- renumberAccEntries() : bool
- Update accounting entry numbers.
- saveInsert() : bool
- saveUpdate() : bool
- Este método se llama al actualizar un registro existente en la base de datos.
Constants
OPERATION_CLOSING
public
mixed
OPERATION_CLOSING
= 'C'
OPERATION_GENERAL
public
mixed
OPERATION_GENERAL
= null
OPERATION_OPENING
public
mixed
OPERATION_OPENING
= 'A'
OPERATION_REGULARIZATION
public
mixed
OPERATION_REGULARIZATION
= 'R'
RENUMBER_LIMIT
public
mixed
RENUMBER_LIMIT
= 1000
Properties
$canal
Accounting channel. For statistics purpose.
public
int
$canal
$codejercicio
Exercise code.
public
string
$codejercicio
$concepto
Accounting entry concept.
public
string
$concepto
$debe
public
float
$debe
= 0.0
$documento
Document associated with the accounting entry.
public
string
$documento
$editable
True if it is editable, but false.
public
bool
$editable
$fecha
Date of the accounting entry.
public
string
$fecha
$haber
public
float
$haber
= 0.0
$idasiento
Primary key.
public
int
$idasiento
$iddiario
Diary identifier.
public
int
$iddiario
$idempresa
Foreign Key with Empresas table.
public
int
$idempresa
$importe
Amount of the accounting entry.
public
float|int
$importe
$numero
Accounting entry number. It will be modified when renumbering.
public
string
$numero
$operacion
It establishes whether the accounting entry is of a special operation: - opening - regularization - closing
public
string
$operacion
$attributes
The model's attributes.
protected
array<string|int, mixed>
$attributes
= []
$dataBase
It provides direct access to the database.
protected
static DataBase
$dataBase
$fields
List of fields in the table.
protected
static array<string|int, mixed>
$fields
= []
$original
The model's original attributes.
protected
array<string|int, mixed>
$original
= []
Methods
__construct()
public
__construct([array<string|int, mixed> $data = [] ]) : mixed
Parameters
- $data : array<string|int, mixed> = []
__get()
public
__get(string $key) : mixed
Parameters
- $key : string
__isset()
public
__isset(string $key) : bool
Parameters
- $key : string
Return values
bool__set()
public
__set(string $key, mixed $value) : void
Parameters
- $key : string
- $value : mixed
__unset()
public
__unset(string $key) : void
Parameters
- $key : string
accumulateAmounts()
Accumulate the amounts of the detail in the document
public
accumulateAmounts(array<string|int, mixed> &$detail) : mixed
Parameters
- $detail : array<string|int, mixed>
addExtension()
public
abstract static addExtension(mixed $extension[, int $priority = 100 ]) : void
Parameters
- $extension : mixed
- $priority : int = 100
all()
Devuelve todos los registros que cumplen las condiciones.
public
static all([array<string|int, mixed> $where = [] ][, array<string|int, mixed> $order = [] ][, int $offset = 0 ][, int $limit = 0 ]) : array<string|int, static>
Parameters
- $where : array<string|int, mixed> = []
- $order : array<string|int, mixed> = []
- $offset : int = 0
- $limit : int = 0
Return values
array<string|int, static>changeId()
public
changeId(mixed $new_id) : bool
Parameters
- $new_id : mixed
Return values
boolchangePrimaryColumnValue()
public
changePrimaryColumnValue(mixed $new_id) : bool
replace with changeId()
Parameters
- $new_id : mixed
Return values
boolclear()
public
clear() : void
clearCache()
public
clearCache() : void
count()
public
static count([array<string|int, mixed> $where = [] ]) : int
Parameters
- $where : array<string|int, mixed> = []
Return values
intcreate()
public
static create(array<string|int, mixed> $data) : static|null
Parameters
- $data : array<string|int, mixed>
Return values
static|nulldelete()
public
delete() : bool
Return values
booldeleteWhere()
public
static deleteWhere(array<string|int, mixed> $where) : bool
Parameters
- $where : array<string|int, mixed>
Return values
booleditable()
public
editable() : bool
Return values
boolexists()
public
exists() : bool
Return values
boolfind()
public
static find(mixed $code) : static|null
Parameters
- $code : mixed
Return values
static|nullfindOrCreate()
public
static findOrCreate(array<string|int, mixed> $where[, array<string|int, mixed> $data = [] ]) : static|null
Parameters
- $where : array<string|int, mixed>
- $data : array<string|int, mixed> = []
Return values
static|nullfindWhere()
public
static findWhere(array<string|int, mixed> $where[, array<string|int, mixed> $order = [] ]) : static|null
Parameters
- $where : array<string|int, mixed>
- $order : array<string|int, mixed> = []
Return values
static|nullfindWhereEq()
public
static findWhereEq(string $field, mixed $value) : static|null
Parameters
- $field : string
- $value : mixed
Return values
static|nullget()
public
get(mixed $code) : mixed
Use find() instead
Parameters
- $code : mixed
getApiFieldsToHide()
Devuelve los nombres de campos que no deben exponerse en la API (ni en GET, ni en el schema). Los modelos con datos sensibles deben sobrescribir este método.
public
getApiFieldsToHide() : array<string|int, string>
Return values
array<string|int, string>getDirty()
Devuelve un array asociativo con los campos modificados y sus valores actuales.
public
getDirty() : array<string|int, mixed>
Return values
array<string|int, mixed>getExercise()
public
getExercise([string $codejercicio = '' ]) : Ejercicio
Parameters
- $codejercicio : string = ''
Return values
EjerciciogetLines()
public
getLines() : array<string|int, Partida>
Return values
array<string|int, Partida>getModelFields()
Returns the list of fields in the table.
public
getModelFields() : array<string|int, mixed>
Return values
array<string|int, mixed>getNewLine()
public
getNewLine([Subcuenta|null $subcuenta = null ]) : Partida
Parameters
- $subcuenta : Subcuenta|null = null
Return values
PartidagetOriginal()
Devuelve el valor original de un campo, si no se indica campo devuelve todo el array original
public
getOriginal([string|null $key = null ]) : mixed|null
Parameters
- $key : string|null = null
Return values
mixed|null —Devuelve el valor original del campo o null si no existe
hasChanged()
public
hasChanged(string $field) : bool
replace with isDirty()
Parameters
- $field : string
Return values
boolhasColumn()
public
hasColumn(string $columnName) : bool
Parameters
- $columnName : string
Return values
boolhasExtension()
public
abstract hasExtension(mixed $extension) : bool
Parameters
- $extension : mixed
Return values
boolid()
public
id() : mixed
initTotals()
Initializes the total fields
public
initTotals() : mixed
install()
public
install() : string
Return values
stringisBalanced()
Returns TRUE if accounting entry is balanced.
public
isBalanced() : bool
Return values
boolisDirty()
Comprueba si los campos del modelo han sido modificados.
public
isDirty([string|null $key = null ]) : bool
Devuelve true si hay cambios, false en caso contrario.
Si introduces un parámetro key, comprueba solo ese campo
Parameters
- $key : string|null = null
Return values
bool —true si ha sido modificado, false en caso contrario
load()
Carga un modelo dada su primary key
public
load(mixed $code) : bool
Parameters
- $code : mixed
-
Código o identificador del registro a cargar
Return values
bool —Devuelve true si se encontró y cargó un registro exitosamente.
loadFromCode()
Carga un registro del modelo utilizando un código y opcionalmente condiciones adicionales.
public
loadFromCode(mixed $code[, array<string|int, mixed> $where = [] ][, array<string|int, mixed> $order = [] ]) : bool
Usar load() cuando solo se necesita cargar por código, o loadWhere() cuando se requieren condiciones WHERE u ordenamiento adicionales.
IMPORTANTE: Este método está deprecado. Se recomienda usar las alternativas siguientes:
- Si solo se proporciona $code: usar directamente load($code)
- Si se proporciona $code junto con $where o $order: usar loadWhere() con las condiciones apropiadas
Este método actúa como wrapper que redirige a load() cuando solo se proporciona el código, o a loadWhere() cuando se incluyen condiciones WHERE u ordenamiento adicionales.
Parameters
- $code : mixed
-
Código o identificador del registro a cargar. Se usa únicamente cuando no se proporcionan condiciones WHERE adicionales.
- $where : array<string|int, mixed> = []
-
Array de instancias de Where o DatabaseWhere que definen condiciones de filtrado adicionales. Si se proporciona, el método delega a loadWhere(). Por defecto es un array vacío.
- $order : array<string|int, mixed> = []
-
Array asociativo que define el ordenamiento de los resultados. Las claves son nombres de columnas y los valores la dirección del ordenamiento. Por defecto es un array vacío.
Return values
bool —Retorna true si se encontró y cargó un registro exitosamente. Retorna false si no se encontró ningún registro.
loadFromData()
public
loadFromData([array<string|int, mixed> $data = [] ][, array<string|int, mixed> $exclude = [] ][, bool $sync = true ]) : void
Parameters
- $data : array<string|int, mixed> = []
- $exclude : array<string|int, mixed> = []
- $sync : bool = true
loadWhere()
Carga el primer registro que coincida con las condiciones especificadas.
public
loadWhere(array<string|int, mixed> $where[, array<string|int, mixed> $order = [] ]) : bool
Este método consulta la tabla asociada al modelo aplicando las condiciones WHERE proporcionadas y el ordenamiento especificado. Si encuentra un registro, carga sus datos en la instancia actual del modelo. Si no encuentra ningún registro, limpia la instancia y retorna false.
Parameters
- $where : array<string|int, mixed>
-
Array de instancias de Where o DatabaseWhere que definen las condiciones de filtrado para la consulta. Cada elemento representa una condición que debe cumplir el registro a cargar.
- $order : array<string|int, mixed> = []
-
Array asociativo que define el ordenamiento de los resultados. Las claves son nombres de columnas y los valores indican la dirección del ordenamiento (ej: ['id' => 'DESC', 'nombre' => 'ASC']). Por defecto es un array vacío (sin ordenamiento específico).
Return values
bool —Retorna true si se encontró y cargó un registro exitosamente. Retorna false si no se encontró ningún registro que cumpla las condiciones.
loadWhereEq()
public
loadWhereEq(string $field, mixed $value) : bool
Parameters
- $field : string
- $value : mixed
Return values
boolmodelClassName()
Returns the name of the class of the model.
public
modelClassName() : string
Return values
stringnewCode()
Returns the following code for the reported field or the primary key of the model.
public
newCode([string $field = '' ][, array<string|int, mixed> $where = [] ]) : int
Parameters
- $field : string = ''
- $where : array<string|int, mixed> = []
Return values
intpipe()
public
abstract pipe(mixed $name, mixed ...$arguments) : mixed
Parameters
- $name : mixed
- $arguments : mixed
pipeFalse()
public
abstract pipeFalse(mixed $name, mixed ...$arguments) : bool
Parameters
- $name : mixed
- $arguments : mixed
Return values
boolprimaryColumn()
public
static primaryColumn() : string
Return values
stringprimaryColumnValue()
public
primaryColumnValue() : mixed
Use id() instead
Attributes
- #[Deprecated]
- $reason: 'Use id() instead'
- $replacement: '%class%->id()'
primaryDescription()
public
primaryDescription() : mixed
primaryDescriptionColumn()
public
primaryDescriptionColumn() : string
Return values
stringreload()
public
reload() : bool
Return values
boolrenumber()
Renumber the accounting entries of the given exercise.
public
renumber(string $codejercicio) : bool
Parameters
- $codejercicio : string
Return values
boolsave()
Guarda el modelo en la base de datos después de ejecutar las comprobaciones `$this->test()`
public
save() : bool
Return values
bool —Devuelve true si se ha guardado correctamente, false en caso contrario
setDate()
public
setDate(string $date) : bool
Parameters
- $date : string
Return values
boolsyncOriginal()
public
syncOriginal() : void
table()
public
static table() : DbQuery
Return values
DbQuerytableName()
public
static tableName() : string
Return values
stringtest()
Realiza pruebas de validación sobre los campos del modelo antes de guardarlo.
public
test() : bool
Return values
bool —Devuelve true si todas las pruebas pasan, false en caso contrario
toArray()
Devuelve un array con los campos y valores del modelo.
public
toArray([bool $dynamic_attributes = false ]) : array<string|int, mixed>
Parameters
- $dynamic_attributes : bool = false
-
Si es true, añade también los atributos dinámicos al array resultante
Return values
array<string|int, mixed> —Array asociativo con los campos y valores del modelo
totalSum()
public
static totalSum(string $field[, array<string|int, mixed> $where = [] ]) : float
Parameters
- $field : string
- $where : array<string|int, mixed> = []
Return values
floatupdate()
Actualiza el modelo con los valores proporcionados en el array
public
update(array<string|int, mixed> $values) : bool
Parameters
- $values : array<string|int, mixed>
-
Array asociativo con los campos y valores a actualizar
Return values
bool —Devuelve true si la actualización se ha realizado correctamente, false en caso
updateOrCreate()
public
static updateOrCreate(array<string|int, mixed> $where, array<string|int, mixed> $data) : static|null
Parameters
- $where : array<string|int, mixed>
- $data : array<string|int, mixed>
Return values
static|nullurl()
Genera una URL para el modelo según el tipo especificado.
public
url([string $type = 'auto' ][, string $list = 'List' ]) : string
Parameters
- $type : string = 'auto'
-
Tipo de URL a generar. Puede ser 'auto', 'edit', 'list' o 'new'.
- $list : string = 'List'
-
Nombre de la lista a utilizar en la URL cuando el tipo es 'list' o 'auto'.
Return values
string —URL generada para el modelo
belongsTo()
Define una relación uno a uno.
protected
belongsTo(string $modelName, string $foreignKey) : object|null
Parameters
- $modelName : string
- $foreignKey : string
Return values
object|nulldb()
protected
abstract static db() : DataBase
Return values
DataBasehasMany()
Define a one-to-many relationship.
protected
hasMany(string $modelName, string $foreignKey[, array<string|int, mixed> $where = [] ][, array<string|int, mixed> $order = [] ]) : array<string|int, mixed>
Parameters
- $modelName : string
- $foreignKey : string
- $where : array<string|int, mixed> = []
- $order : array<string|int, mixed> = []
Return values
array<string|int, mixed>loadModelFields()
protected
loadModelFields() : void
onChange()
Este método se llama antes de guardar (insertar) un nuevo registro en la base de datos.
protected
onChange(string $field) : bool
Parameters
- $field : string
Return values
boolonDelete()
Este método se llama al eliminar un registro de la base de datos.
protected
onDelete() : void
onInsert()
Este método se llama al insertar un nuevo registro en la base de datos (saveInsert).
protected
onInsert() : void
onUpdate()
Este método se llama al insertar un nuevo registro en la base de datos (saveUpdate).
protected
onUpdate() : void
renumberAccEntries()
Update accounting entry numbers.
protected
renumberAccEntries(array<string|int, mixed> &$entries, int &$number) : bool
Parameters
- $entries : array<string|int, mixed>
- $number : int
Return values
boolsaveInsert()
protected
saveInsert() : bool
Return values
boolsaveUpdate()
Este método se llama al actualizar un registro existente en la base de datos.
protected
saveUpdate() : bool
Return values
bool —Devuelve true si la actualización se realizó correctamente, false en caso contrario