FacturaScripts

BusinessDocumentLine extends ModelOnChangeClass Uses TaxRelationTrait

Description of BusinessDocumentLine

Table of Contents

$actualizastock Update stock status. int
$cantidad Quantity. float|int
$descripcion Description of the line. string
$disableUpdateStock bool
$dtopor Percentage of discount. float|int
$dtopor2 Percentage of seccond discount. float|int
$idlinea Primary key. int
$idproducto int
$irpf % of IRPF of the line. float|int
$iva % of the related tax. float|int
$orden Position of the line in the document. The higher down. int
$pvpsindto Net amount without discounts. float|int
$pvptotal Net amount of the line, without taxes. float|int
$pvpunitario Price of the item, one unit. float|int
$recargo % surcharge of line equivalence. float|int
$referencia Reference of the article. string
$servido Served. float|int
$suplido bool
$codimpuesto Tax identifier of the tax assigned. string
$taxes Containt all avaliable taxes. \FacturaScripts\Dinamic\Model\Impuesto[]
$previousData Previous data array. array
$checkedTables List of already tested tables. array
$dataBase It provides direct access to the database. DataBase
getDocument() Returns the parent document of this line. mixed
documentColumn() Returns the name of the column to store the document's identifier. mixed
clear() Reset the values of all model properties. mixed
disableUpdateStock() mixed
documentColumnValue() Returns the identifier of the document. int
getEUDiscount() Returns the Equivalent Unified Discount. float
getProducto() Returns related product. Producto
install() string
primaryColumn() Returns the name of the column that is the model's primary key. string
test() Returns True if there is no errors on properties values. bool
transfer() Transfers the line stock from one warehouse to another. bool
url() Custom url method. string
applyStockChanges() Apply stock modifications according to $mode. mixed
onChange() This method is called before save (update) in the database this record data when some field value has changed. bool
onDelete() This method is called after this record is deleted from database. mixed
saveInsert() Inserts this data as a new record in database. bool
setPreviousData() Saves previous values. mixed
updateStock() Updates stock according to line data and $codalmacen warehouse. bool
getTax() Returns the current tax or the default one Impuesto
__construct() ModelClass constructor. mixed
delete() Remove the model data from the database. bool
loadFromCode() Fill the class with the registry values whose primary column corresponds to the value $cod, or according to the condition where indicated, if value is not reported in $cod. bool
onChange() This method is called before save (update) when some field has changed. bool
onDelete() This method is called after a record is removed from the database. mixed
onInsert() This method is called after a new record is saved on the database (saveInsert). mixed
onUpdate() This method is called after a record is updated on the database (saveUpdate). mixed
saveInsert() Insert the model data in the database. bool
saveUpdate() Update the model data in the database. bool
setPreviousData() Saves previous values. mixed
all() Returns all models that correspond to the selected filters. static[]
codeModelAll() Allows to use this model as source in CodeModel special model. \FacturaScripts\Dinamic\Model\CodeModel[]
codeModelSearch() Allows to use this model as source in CodeModel special model. \FacturaScripts\Dinamic\Model\CodeModel[]
count() Returns the number of records in the model that meet the condition. int
exists() Returns true if the model data is stored in the database. bool
get() Returns the model whose primary column corresponds to the value $cod static|bool
newCode() Returns the following code for the reported field or the primary key of the model. int
primaryDescriptionColumn() Returns the name of the column that describes the model, such as name, description. string
primaryDescription() Descriptive identifier for humans of the data record string
save() Stores the model data in the database. bool
test() Returns true if there are no errors in the values of the model properties. bool
url() Returns the url where to see / modify the data. string
getOrderBy() Convert an array of filters order by in string. string
getRecord() Read the record whose primary column corresponds to the value $cod or the first that meets the indicated condition. array
addExtension() Adds an extension to this model. mixed
getModelFields() Returns the list of fields in the table. array
loadModelFields() Loads table fields if is necessary. mixed
modelClassName() Returns the name of the class of the model. string
modelName() Returns the name of the model. string
pipe() Executes all $name methods added from the extensions. mixed
primaryColumn() Returns the name of the column that is the model's primary key. string
tableName() Returns the name of the table that uses this model. string
changePrimaryColumnValue() Change the value of the primary column in the model and the database. bool
clear() Reset the values of all model properties. mixed
install() This function is called when creating the model table. Returns the SQL that will be executed after the creation of the table. Useful to insert values default. string
loadFromData() Assign the values of the $data array to the model properties. mixed
primaryColumnValue() Returns the current value of the main column of the model. mixed
toArray() Returns an array with the model fields values. array
checkTable() Checks and updates the structure of the table if necessary. bool
getBoolValueForField() Returns the boolean value for the field. bool|null
getFloatValueForField() Returns the float value for the field. float|null
getIntergerValueForField() Returns the integer value by controlling special cases for the PK and FK. int|null
toolBox() ToolBox

Properties

$codimpuesto

Tax identifier of the tax assigned.

public string $codimpuesto

$taxes

Containt all avaliable taxes.

private static \FacturaScripts\Dinamic\Model\Impuesto[] $taxes = []

$checkedTables

List of already tested tables.

private static array $checkedTables = []

$dataBase

It provides direct access to the database.

protected static DataBase $dataBase

Methods

getDocument()

Returns the parent document of this line.

public abstract getDocument( ) : mixed
Return values
mixed

documentColumn()

Returns the name of the column to store the document's identifier.

public abstract documentColumn( ) : mixed
Return values
mixed

clear()

Reset the values of all model properties.

public clear( ) : mixed
Return values
mixed

disableUpdateStock()

public disableUpdateStock( $value : bool ) : mixed
Parameters
$value : bool
Return values
mixed

documentColumnValue()

Returns the identifier of the document.

public documentColumnValue( ) : int
Return values
int

getEUDiscount()

Returns the Equivalent Unified Discount.

public getEUDiscount( ) : float
Return values
float

primaryColumn()

Returns the name of the column that is the model's primary key.

public static primaryColumn( ) : string
Return values
string

test()

Returns True if there is no errors on properties values.

public test( ) : bool
Return values
bool

transfer()

Transfers the line stock from one warehouse to another.

public transfer( $fromCodalmacen : string , $toCodalmacen : string ) : bool
Parameters
$fromCodalmacen : string
$toCodalmacen : string
Return values
bool

url()

Custom url method.

public url( [ $type : string = 'auto' ] [, $list : string = 'List' ] ) : string
Parameters
$type : string = 'auto'
$list : string = 'List'
Return values
string

applyStockChanges()

Apply stock modifications according to $mode.

private applyStockChanges( &$stock : Stock , $mode : int , $quantity : float , $served : float ) : mixed
Parameters
$stock : Stock
$mode : int
$quantity : float
$served : float
Return values
mixed

onChange()

This method is called before save (update) in the database this record data when some field value has changed.

protected onChange( $field : string ) : bool
Parameters
$field : string
Return values
bool

onDelete()

This method is called after this record is deleted from database.

protected onDelete( ) : mixed
Return values
mixed

saveInsert()

Inserts this data as a new record in database.

protected saveInsert( [ $values : array = [] ] ) : bool
Parameters
$values : array = []
Return values
bool

setPreviousData()

Saves previous values.

protected setPreviousData( [ $fields : array = [] ] ) : mixed
Parameters
$fields : array = []
Return values
mixed

updateStock()

Updates stock according to line data and $codalmacen warehouse.

protected updateStock( ) : bool
Return values
bool

__construct()

ModelClass constructor.

public __construct( [ $data : array = [] ] ) : mixed
Parameters
$data : array = []
Return values
mixed

delete()

Remove the model data from the database.

public delete( ) : bool
Return values
bool

loadFromCode()

Fill the class with the registry values whose primary column corresponds to the value $cod, or according to the condition where indicated, if value is not reported in $cod.

public loadFromCode( $code : string [, $where : array = [] ] [, $orderby : array = [] ] ) : bool

Initializes the values of the class if there is no record that meet the above conditions. Returns True if the record exists and False otherwise.

Parameters
$code : string
$where : array = []
$orderby : array = []
Return values
bool

onChange()

This method is called before save (update) when some field has changed.

protected onChange( $field : string ) : bool
Parameters
$field : string
Return values
bool

onDelete()

This method is called after a record is removed from the database.

protected onDelete( ) : mixed
Return values
mixed

onInsert()

This method is called after a new record is saved on the database (saveInsert).

protected onInsert( ) : mixed
Return values
mixed

onUpdate()

This method is called after a record is updated on the database (saveUpdate).

protected onUpdate( ) : mixed
Return values
mixed

saveInsert()

Insert the model data in the database.

protected saveInsert( [ $values : array = [] ] ) : bool
Parameters
$values : array = []
Return values
bool

saveUpdate()

Update the model data in the database.

protected saveUpdate( [ $values : array = [] ] ) : bool
Parameters
$values : array = []
Return values
bool

setPreviousData()

Saves previous values.

protected setPreviousData( [ $fields : array = [] ] ) : mixed
Parameters
$fields : array = []
Return values
mixed

all()

Returns all models that correspond to the selected filters.

public all( [ $where : array = [] ] [, $order : array = [] ] , $offset : int [, $limit : int = 50 ] ) : static[]
Parameters
$where : array = []

filters to apply to model records.

$order : array = []

fields to use in the sorting. For example ['code' => 'ASC']

$offset : int
$limit : int = 50
Return values
static[]

codeModelAll()

Allows to use this model as source in CodeModel special model.

public codeModelAll( [ $fieldCode : string = '' ] ) : \FacturaScripts\Dinamic\Model\CodeModel[]
Parameters
$fieldCode : string = ''
Return values
\FacturaScripts\Dinamic\Model\CodeModel[]

codeModelSearch()

Allows to use this model as source in CodeModel special model.

public codeModelSearch( $query : string [, $fieldCode : string = '' ] [, $where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[] = [] ] ) : \FacturaScripts\Dinamic\Model\CodeModel[]
Parameters
$query : string
$fieldCode : string = ''
$where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[] = []
Return values
\FacturaScripts\Dinamic\Model\CodeModel[]

count()

Returns the number of records in the model that meet the condition.

public count( [ $where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[] = [] ] ) : int
Parameters
$where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[] = []

filters to apply to model records.

Return values
int

exists()

Returns true if the model data is stored in the database.

public exists( ) : bool
Return values
bool

get()

Returns the model whose primary column corresponds to the value $cod

public get( $code : string ) : static|bool
Parameters
$code : string
Return values
static|bool

newCode()

Returns the following code for the reported field or the primary key of the model.

public newCode( [ $field : string = '' ] [, $where : array = [] ] ) : int
Parameters
$field : string = ''
$where : array = []
Return values
int

primaryDescriptionColumn()

Returns the name of the column that describes the model, such as name, description.

public primaryDescriptionColumn( ) : string

..

Return values
string

primaryDescription()

Descriptive identifier for humans of the data record

public primaryDescription( ) : string
Return values
string

save()

Stores the model data in the database.

public save( ) : bool
Return values
bool

test()

Returns true if there are no errors in the values of the model properties.

public test( ) : bool

It runs inside the save method.

Return values
bool

url()

Returns the url where to see / modify the data.

public url( [ $type : string = 'auto' ] [, $list : string = 'List' ] ) : string
Parameters
$type : string = 'auto'
$list : string = 'List'
Return values
string

getOrderBy()

Convert an array of filters order by in string.

private getOrderBy( $order : array ) : string
Parameters
$order : array
Return values
string

getRecord()

Read the record whose primary column corresponds to the value $cod or the first that meets the indicated condition.

private getRecord( $code : string [, $where : array = [] ] [, $orderby : array = [] ] ) : array
Parameters
$code : string
$where : array = []
$orderby : array = []
Return values
array

addExtension()

Adds an extension to this model.

public abstract static addExtension( $extension : mixed ) : mixed
Parameters
$extension : mixed
Return values
mixed

getModelFields()

Returns the list of fields in the table.

public abstract getModelFields( ) : array
Return values
array

loadModelFields()

Loads table fields if is necessary.

protected abstract loadModelFields( &$dataBase : DataBase , $tableName : string ) : mixed
Parameters
$dataBase : DataBase
$tableName : string
Return values
mixed

modelClassName()

Returns the name of the class of the model.

public abstract modelClassName( ) : string
Return values
string

modelName()

Returns the name of the model.

protected abstract modelName( ) : string
Return values
string

pipe()

Executes all $name methods added from the extensions.

public abstract pipe( $name : string , ...$arguments : array ) : mixed
Parameters
$name : string
$arguments : array
Return values
mixed

primaryColumn()

Returns the name of the column that is the model's primary key.

public abstract static primaryColumn( ) : string
Return values
string

tableName()

Returns the name of the table that uses this model.

public abstract static tableName( ) : string
Return values
string

changePrimaryColumnValue()

Change the value of the primary column in the model and the database.

public changePrimaryColumnValue( $newValue : mixed ) : bool
Parameters
$newValue : mixed
Return values
bool

clear()

Reset the values of all model properties.

public clear( ) : mixed
Return values
mixed

install()

This function is called when creating the model table. Returns the SQL that will be executed after the creation of the table. Useful to insert values default.

public install( ) : string
Return values
string

loadFromData()

Assign the values of the $data array to the model properties.

public loadFromData( [ $data : array = [] ] [, $exclude : array = [] ] ) : mixed
Parameters
$data : array = []
$exclude : array = []
Return values
mixed

primaryColumnValue()

Returns the current value of the main column of the model.

public primaryColumnValue( ) : mixed
Return values
mixed

toArray()

Returns an array with the model fields values.

public toArray( ) : array
Return values
array

checkTable()

Checks and updates the structure of the table if necessary.

private checkTable( ) : bool
Return values
bool

getBoolValueForField()

Returns the boolean value for the field.

private getBoolValueForField( $field : array , $value : string ) : bool|null
Parameters
$field : array
$value : string
Return values
bool|null

getFloatValueForField()

Returns the float value for the field.

private getFloatValueForField( $field : array , $value : string ) : float|null
Parameters
$field : array
$value : string
Return values
float|null

getIntergerValueForField()

Returns the integer value by controlling special cases for the PK and FK.

private getIntergerValueForField( $field : array , $value : string ) : int|null
Parameters
$field : array
$value : string
Return values
int|null

Search results