Академический Документы
Профессиональный Документы
Культура Документы
reglas y frmulas
Orden de ejecucin de
reglas y frmulas
Transaccin "Invoice"
InvoiceId*
InvoiceDate
CustomerId
CustomerTotalPurchases
CategoryDiscount
InvoiceDiscount
= InvoiceSubTotal *CategoryDiscount
InvoiceShippingCharge = Max( ShippingDate, ShippingDate
<=InvoiceDate,,ShippingCharge)
InvoiceSubTotal
= SUM( InvoiceDetailAmount )
InvoiceTotal
= InvoiceSubTotal InvoiceDiscount
+ InvoiceShippingCharge
(ProductId*
ProductPrice
ProductStock
InvoiceDetailQuantity
InvoiceDetailAmount) = InvoiceDetailQuantity *
ProductPrice
Reglas:
Customer
CustomerId*
CustomerName
CategoryId
CustomerTotalPurchases
Category
CategoryId*
CategoryDiscount
Shipping
ShippingDate*
ShippingCharge
Product
ProductId*
ProductPrice
ProducStock
rbol de evaluacin
R. Add(InvoiceTotal, CustomerTotalPurchases);
F. InvoiceTotal = InvoiceSubTotal - InvoiceDiscount +
InvoiceShippingCharge
CustomerTotalPurchases
F. InvoiceDiscount = InvoiceSubTotal*CategoryDiscount
F. InvoiceShippingCharge = MAX( ShippingDate, ShippingDate <=
InvoiceDate,,ShippingCharge)
F. InvoiceSubTotal = SUM( InvoiceDetailAmount )
F. InvoiceDetailAmount = InvoiceDetailQuantity *ProductPrice
InvoiceTotal
R. Subtract(InvoiceDetailQuantity, ProductStock) ;
R. Error( Insuffcient Stock) if ProductStock < 0 ;
InvoiceDiscount
InvoiceShippingChar
ge
ShippingDate
InvoiceDetailQuantity
ProductPrice
InvoiceDate
ShippingCharge
Total
Calculad
o
Total
Ingresado
SupplierId*
InvoiceId*
...
InvoiceDetailAmount
InvoiceEntTotal
Entered Total
( ProductId*
InvoiceDetailQuantity
InvoiceDetailPrice
InvoiceDetailAmount = InvoiceDetailPrice * InvoiceDetailQuantity)
...
InvoiceCalcTotal = SUM(InvoiceDetailAmount) Calculated Total
Error(The calculated total doesnt match with the entered total') if
(InvoiceEntTotal<>InvoiceCalcTotal) On AfterLevel Level ProductId;
Eventos de disparo
La mayora de las reglas de transacciones permiten que se les
agregue de ser necesario un evento o momento de disparo.
Al agregar un evento o momento de disparo a una regla,
estaremos especificando que la regla se deber ejecutar en ese
determinado momento.
Eventos de disparo:
BeforeValidate
AfterValidate
BeforeInsert, BeforeUpdate, BeforeDelete
AfterInsert, AfterUpdate, AfterDelete
AfterLevel
BeforeComplete
AfterComplete
REGLAS STAND-ALONE
EVALUACION DE REGLAS
Y
FORMULAS SEGN
ARBOL
PARA CADA
LINEA
EVALUACION DE
REGLAS Y
FORMULAS
SEGN ARBOL
REGLAS STAND-ALONE
EVALUACION REGLAS Y FRMULAS SEGN
ARBOL
BeforeValidate
VALIDACIN
AfterValidate / BeforeInsert / Update / Delete
GRABACION DEL
CABEZAL / Update / Delete
AfterInsert
EVALUACION DE REGLAS
PARA
Y
CADA
FORMULAS SEGN
LINEA
BeforeValidate
ARBOL
VALIDACIN
AfterValidate / BeforeInsert / Udpate /
Delete
GRABACION DE LA LINEA
AfterInsert/Update/Del
ete
ABANDONAR NIVEL 2
AfterLevel Level attNivel2 BeforeComplete
COMMIT
AfterComplete
Ejemplos
Cundo se dispararn las siguientes reglas?
Something.call( InvoiceId ) if Insert;
Luego de validado el campo InvoiceId e inferido que se est en modo Insert
Ejemplos
Algunas reglas estn mal programadas. Cules?
InvoiceDate = &today on AfterInsert;
Incorrecto: El ltimo momento para asignar valor a un atributo del cabezal
es inmediatamente antes de su grabacin (BeforeInsert)
Ejemplo 2
pgmname.call( CustomerId, &flag) On AfterComplete;
error('
') if &flag = 'N On AfterComplete;
Eventos en Transacciones
Eventos en Transacciones
Evento Start
Evento User Event
Evento After Trn
Evento Exit
Evento TrackContext
Eventos Start
Start: Se ejecuta cada vez que se somete el
form de una transaccin al servidor.
SINTAXIS: Event Start
cdigo
EndEvent
Eventos de Usuario
Adems de los eventos ofrecidos por GeneXus, el analista puede
definir eventos creados por l, llamados eventos de usuario.
Propiedades
Web:
Orden de
ejecucin
1. Evento Start
2. Lectura de atributos y variables del form
3. Evento de usuario seleccionado
Ejemplo: