- Usar el nuevo servicio de gestión de referencias en los módulos de la aplicación
- En la BD, añadir clave primario ID y generador para la table REFERENCIAS git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@170 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
parent
34bc7dddb2
commit
72b1fcf24c
Binary file not shown.
@ -85,25 +85,25 @@ CREATE GENERATOR GEN_AGENTES_COMISIONES_ID;
|
|||||||
SET GENERATOR GEN_AGENTES_COMISIONES_ID TO 0;
|
SET GENERATOR GEN_AGENTES_COMISIONES_ID TO 0;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_ALBARANES_CLI_DETALLES_ID;
|
CREATE GENERATOR GEN_ALBARANES_CLI_DETALLES_ID;
|
||||||
SET GENERATOR GEN_ALBARANES_CLI_DETALLES_ID TO 4;
|
SET GENERATOR GEN_ALBARANES_CLI_DETALLES_ID TO 7;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_ALBARANES_CLI_ID;
|
CREATE GENERATOR GEN_ALBARANES_CLI_ID;
|
||||||
SET GENERATOR GEN_ALBARANES_CLI_ID TO 7;
|
SET GENERATOR GEN_ALBARANES_CLI_ID TO 10;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_ALBARANES_PRO_DETALLES_ID;
|
CREATE GENERATOR GEN_ALBARANES_PRO_DETALLES_ID;
|
||||||
SET GENERATOR GEN_ALBARANES_PRO_DETALLES_ID TO 3;
|
SET GENERATOR GEN_ALBARANES_PRO_DETALLES_ID TO 4;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_ALBARANES_PRO_ID;
|
CREATE GENERATOR GEN_ALBARANES_PRO_ID;
|
||||||
SET GENERATOR GEN_ALBARANES_PRO_ID TO 2;
|
SET GENERATOR GEN_ALBARANES_PRO_ID TO 3;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_ALMACENES_ID;
|
CREATE GENERATOR GEN_ALMACENES_ID;
|
||||||
SET GENERATOR GEN_ALMACENES_ID TO 3;
|
SET GENERATOR GEN_ALMACENES_ID TO 4;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_ARTICULOS_ID;
|
CREATE GENERATOR GEN_ARTICULOS_ID;
|
||||||
SET GENERATOR GEN_ARTICULOS_ID TO 5;
|
SET GENERATOR GEN_ARTICULOS_ID TO 6;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_CATEGORIAS_ID;
|
CREATE GENERATOR GEN_CATEGORIAS_ID;
|
||||||
SET GENERATOR GEN_CATEGORIAS_ID TO 0;
|
SET GENERATOR GEN_CATEGORIAS_ID TO 4;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_CLIENTES_DTOS_PROV_ID;
|
CREATE GENERATOR GEN_CLIENTES_DTOS_PROV_ID;
|
||||||
SET GENERATOR GEN_CLIENTES_DTOS_PROV_ID TO 0;
|
SET GENERATOR GEN_CLIENTES_DTOS_PROV_ID TO 0;
|
||||||
@ -115,10 +115,10 @@ CREATE GENERATOR GEN_CONTACTOS_DATOS_BANCO_ID;
|
|||||||
SET GENERATOR GEN_CONTACTOS_DATOS_BANCO_ID TO 0;
|
SET GENERATOR GEN_CONTACTOS_DATOS_BANCO_ID TO 0;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_CONTACTOS_DIR_ID;
|
CREATE GENERATOR GEN_CONTACTOS_DIR_ID;
|
||||||
SET GENERATOR GEN_CONTACTOS_DIR_ID TO 5;
|
SET GENERATOR GEN_CONTACTOS_DIR_ID TO 8;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_CONTACTOS_ID;
|
CREATE GENERATOR GEN_CONTACTOS_ID;
|
||||||
SET GENERATOR GEN_CONTACTOS_ID TO 2001;
|
SET GENERATOR GEN_CONTACTOS_ID TO 29;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_EMPRESAS_DATOS_BANCO_ID;
|
CREATE GENERATOR GEN_EMPRESAS_DATOS_BANCO_ID;
|
||||||
SET GENERATOR GEN_EMPRESAS_DATOS_BANCO_ID TO 0;
|
SET GENERATOR GEN_EMPRESAS_DATOS_BANCO_ID TO 0;
|
||||||
@ -130,7 +130,7 @@ CREATE GENERATOR GEN_FACTURAS_CLIENTE_ID;
|
|||||||
SET GENERATOR GEN_FACTURAS_CLIENTE_ID TO 23;
|
SET GENERATOR GEN_FACTURAS_CLIENTE_ID TO 23;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_FACTURAS_PROVEEDOR_ID;
|
CREATE GENERATOR GEN_FACTURAS_PROVEEDOR_ID;
|
||||||
SET GENERATOR GEN_FACTURAS_PROVEEDOR_ID TO 0;
|
SET GENERATOR GEN_FACTURAS_PROVEEDOR_ID TO 1;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_FACTURA_CLIENTE_DETALLES_ID;
|
CREATE GENERATOR GEN_FACTURA_CLIENTE_DETALLES_ID;
|
||||||
SET GENERATOR GEN_FACTURA_CLIENTE_DETALLES_ID TO 20;
|
SET GENERATOR GEN_FACTURA_CLIENTE_DETALLES_ID TO 20;
|
||||||
@ -148,7 +148,7 @@ CREATE GENERATOR GEN_F_PERFILES_ID;
|
|||||||
SET GENERATOR GEN_F_PERFILES_ID TO 0;
|
SET GENERATOR GEN_F_PERFILES_ID TO 0;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_INFORMES_ID;
|
CREATE GENERATOR GEN_INFORMES_ID;
|
||||||
SET GENERATOR GEN_INFORMES_ID TO 0;
|
SET GENERATOR GEN_INFORMES_ID TO 11;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_MOVIMIENTOS_ID;
|
CREATE GENERATOR GEN_MOVIMIENTOS_ID;
|
||||||
SET GENERATOR GEN_MOVIMIENTOS_ID TO 0;
|
SET GENERATOR GEN_MOVIMIENTOS_ID TO 0;
|
||||||
@ -166,16 +166,16 @@ CREATE GENERATOR GEN_PEDIDOS_CLI_ID;
|
|||||||
SET GENERATOR GEN_PEDIDOS_CLI_ID TO 0;
|
SET GENERATOR GEN_PEDIDOS_CLI_ID TO 0;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_PEDIDOS_PROV_DETALLES_ID;
|
CREATE GENERATOR GEN_PEDIDOS_PROV_DETALLES_ID;
|
||||||
SET GENERATOR GEN_PEDIDOS_PROV_DETALLES_ID TO 7;
|
SET GENERATOR GEN_PEDIDOS_PROV_DETALLES_ID TO 9;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_PEDIDOS_PROV_ID;
|
CREATE GENERATOR GEN_PEDIDOS_PROV_ID;
|
||||||
SET GENERATOR GEN_PEDIDOS_PROV_ID TO 2;
|
SET GENERATOR GEN_PEDIDOS_PROV_ID TO 4;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_PRESUPUESTOS_CLI_DETALLE_ID;
|
CREATE GENERATOR GEN_PRESUPUESTOS_CLI_DETALLE_ID;
|
||||||
SET GENERATOR GEN_PRESUPUESTOS_CLI_DETALLE_ID TO 50;
|
SET GENERATOR GEN_PRESUPUESTOS_CLI_DETALLE_ID TO 60;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_PRESUPUESTOS_CLI_ID;
|
CREATE GENERATOR GEN_PRESUPUESTOS_CLI_ID;
|
||||||
SET GENERATOR GEN_PRESUPUESTOS_CLI_ID TO 30;
|
SET GENERATOR GEN_PRESUPUESTOS_CLI_ID TO 34;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_RECIBOS_CLIENTE_ID;
|
CREATE GENERATOR GEN_RECIBOS_CLIENTE_ID;
|
||||||
SET GENERATOR GEN_RECIBOS_CLIENTE_ID TO 6;
|
SET GENERATOR GEN_RECIBOS_CLIENTE_ID TO 6;
|
||||||
@ -183,6 +183,9 @@ SET GENERATOR GEN_RECIBOS_CLIENTE_ID TO 6;
|
|||||||
CREATE GENERATOR GEN_RECIBOS_PROVEEDOR_ID;
|
CREATE GENERATOR GEN_RECIBOS_PROVEEDOR_ID;
|
||||||
SET GENERATOR GEN_RECIBOS_PROVEEDOR_ID TO 0;
|
SET GENERATOR GEN_RECIBOS_PROVEEDOR_ID TO 0;
|
||||||
|
|
||||||
|
CREATE GENERATOR GEN_REFERENCIAS_ID;
|
||||||
|
SET GENERATOR GEN_REFERENCIAS_ID TO 17;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_REMESAS_CLIENTE_ID;
|
CREATE GENERATOR GEN_REMESAS_CLIENTE_ID;
|
||||||
SET GENERATOR GEN_REMESAS_CLIENTE_ID TO 0;
|
SET GENERATOR GEN_REMESAS_CLIENTE_ID TO 0;
|
||||||
|
|
||||||
@ -193,7 +196,7 @@ CREATE GENERATOR GEN_TIENDA_WEB_ID;
|
|||||||
SET GENERATOR GEN_TIENDA_WEB_ID TO 0;
|
SET GENERATOR GEN_TIENDA_WEB_ID TO 0;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_TIPOS_IVA_ID;
|
CREATE GENERATOR GEN_TIPOS_IVA_ID;
|
||||||
SET GENERATOR GEN_TIPOS_IVA_ID TO 9;
|
SET GENERATOR GEN_TIPOS_IVA_ID TO 5;
|
||||||
|
|
||||||
CREATE GENERATOR GEN_USUARIOS_ID;
|
CREATE GENERATOR GEN_USUARIOS_ID;
|
||||||
SET GENERATOR GEN_USUARIOS_ID TO 0;
|
SET GENERATOR GEN_USUARIOS_ID TO 0;
|
||||||
@ -1037,9 +1040,10 @@ CREATE TABLE RECIBOS_PROVEEDOR (
|
|||||||
|
|
||||||
|
|
||||||
CREATE TABLE REFERENCIAS (
|
CREATE TABLE REFERENCIAS (
|
||||||
|
ID TIPO_ID NOT NULL,
|
||||||
|
ID_EMPRESA TIPO_ID,
|
||||||
CODIGO VARCHAR(50) NOT NULL,
|
CODIGO VARCHAR(50) NOT NULL,
|
||||||
VALOR VARCHAR(255) NOT NULL,
|
VALOR VARCHAR(255) NOT NULL,
|
||||||
ID_EMPRESA TIPO_ID,
|
|
||||||
DESCRIPCION VARCHAR(255) COLLATE ES_ES
|
DESCRIPCION VARCHAR(255) COLLATE ES_ES
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2498,6 +2502,7 @@ ALTER TABLE PRESUPUESTOS_CLIENTE_DETALLES ADD CONSTRAINT PK_PRESUPUESTOS_CLIENTE
|
|||||||
ALTER TABLE PROVEEDORES_DATOS ADD CONSTRAINT PK_PROVEEDORES_DATOS PRIMARY KEY (ID_PROVEEDOR);
|
ALTER TABLE PROVEEDORES_DATOS ADD CONSTRAINT PK_PROVEEDORES_DATOS PRIMARY KEY (ID_PROVEEDOR);
|
||||||
ALTER TABLE RECIBOS_CLIENTE ADD CONSTRAINT PK_RECIBOS_CLIENTE PRIMARY KEY (ID);
|
ALTER TABLE RECIBOS_CLIENTE ADD CONSTRAINT PK_RECIBOS_CLIENTE PRIMARY KEY (ID);
|
||||||
ALTER TABLE RECIBOS_PROVEEDOR ADD CONSTRAINT PK_RECIBOS_PROVEEDOR PRIMARY KEY (ID);
|
ALTER TABLE RECIBOS_PROVEEDOR ADD CONSTRAINT PK_RECIBOS_PROVEEDOR PRIMARY KEY (ID);
|
||||||
|
ALTER TABLE REFERENCIAS ADD CONSTRAINT PK_REFERENCIAS PRIMARY KEY (ID);
|
||||||
ALTER TABLE REMESAS_CLIENTE ADD CONSTRAINT PK_REMESAS_CLIENTE PRIMARY KEY (ID);
|
ALTER TABLE REMESAS_CLIENTE ADD CONSTRAINT PK_REMESAS_CLIENTE PRIMARY KEY (ID);
|
||||||
ALTER TABLE REMESAS_PROVEEDOR ADD CONSTRAINT PK_REMESAS_PROVEEDOR PRIMARY KEY (ID);
|
ALTER TABLE REMESAS_PROVEEDOR ADD CONSTRAINT PK_REMESAS_PROVEEDOR PRIMARY KEY (ID);
|
||||||
ALTER TABLE TIENDA_WEB ADD CONSTRAINT PK_TIENDA_WEB PRIMARY KEY (ID);
|
ALTER TABLE TIENDA_WEB ADD CONSTRAINT PK_TIENDA_WEB PRIMARY KEY (ID);
|
||||||
@ -2616,22 +2621,24 @@ RETURNS (
|
|||||||
IMPORTE_TOTAL NUMERIC(11,2),
|
IMPORTE_TOTAL NUMERIC(11,2),
|
||||||
VISIBLE SMALLINT)
|
VISIBLE SMALLINT)
|
||||||
AS
|
AS
|
||||||
declare variable num_capitulos integer;
|
declare variable num_filas integer;
|
||||||
|
declare variable contador integer;
|
||||||
declare variable existe numeric(11,2);
|
declare variable existe numeric(11,2);
|
||||||
declare variable total_acumulado numeric(11,2);
|
declare variable total_acumulado numeric(11,2);
|
||||||
begin
|
begin
|
||||||
num_capitulos = 0;
|
|
||||||
existe = 0;
|
existe = 0;
|
||||||
total_acumulado = 0.0;
|
total_acumulado = 0.0;
|
||||||
|
contador = 0;
|
||||||
|
num_filas = 0;
|
||||||
|
|
||||||
/* ¿Existe el presupuesto? */
|
/* ¿Existe el presupuesto? */
|
||||||
for select count(*)
|
for select count(*)
|
||||||
from presupuestos_cliente_detalles
|
from presupuestos_cliente_detalles
|
||||||
where id_presupuesto = :AID
|
where id_presupuesto = :AID
|
||||||
into :EXISTE
|
into :num_filas
|
||||||
do
|
do
|
||||||
begin
|
begin
|
||||||
if (existe = 0) then
|
if (num_filas = 0) then
|
||||||
suspend;
|
suspend;
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2650,6 +2657,7 @@ begin
|
|||||||
|
|
||||||
if (existe = 1) then
|
if (existe = 1) then
|
||||||
begin
|
begin
|
||||||
|
contador = 0;
|
||||||
/* Existen conceptos sin capitulo */
|
/* Existen conceptos sin capitulo */
|
||||||
for select tipo_detalle, importe_total, coalesce(visible, 1)
|
for select tipo_detalle, importe_total, coalesce(visible, 1)
|
||||||
from presupuestos_cliente_detalles
|
from presupuestos_cliente_detalles
|
||||||
@ -2658,7 +2666,8 @@ begin
|
|||||||
into :TIPO_DETALLE, :IMPORTE_TOTAL, :VISIBLE
|
into :TIPO_DETALLE, :IMPORTE_TOTAL, :VISIBLE
|
||||||
do
|
do
|
||||||
begin
|
begin
|
||||||
if (tipo_detalle <> 'Concepto') then
|
contador = contador + 1;
|
||||||
|
if ((tipo_detalle <> 'Concepto') or (contador = num_filas)) then
|
||||||
begin
|
begin
|
||||||
importe_total = total_acumulado;
|
importe_total = total_acumulado;
|
||||||
tipo_detalle = 'Titulo';
|
tipo_detalle = 'Titulo';
|
||||||
|
|||||||
@ -22,24 +22,26 @@ SET GENERATOR GEN_INFORMES_ID TO 11;
|
|||||||
COMMIT WORK;
|
COMMIT WORK;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_FACTURAS_CLIENTE', '00001', 1, 'Ref. facturas de cliente');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (0, 1, 'REF_FACTURAS_CLIENTE', '00001', 'Ref. facturas de cliente');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_PEDIDOS_CLIENTE', '00001', 1, 'Ref. pedidos de cliente');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (1, 1, 'REF_PEDIDOS_CLIENTE', '00001', 'Ref. pedidos de cliente');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_PEDIDOS_PROVEEDOR', '00001', 1, 'Ref. pedidos de proveedor');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (2, 1, 'REF_PEDIDOS_PROVEEDOR', '00003', 'Ref. pedidos de proveedor');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_ALBARANES_CLIENTE', '00001', 1, 'Ref. albaranes de cliente');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (3, 1, 'REF_ALBARANES_CLIENTE', '00004', 'Ref. albaranes de cliente');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_ALBARANES_PROVEEDOR', '00001', 1, 'Ref. albaranes de proveedor');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (4, 1, 'REF_ALBARANES_PROVEEDOR', '00002', 'Ref. albaranes de proveedor');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_REMESAS_CLIENTE', '00001', 1, 'Ref. remesas de cliente');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (5, 1, 'REF_REMESAS_CLIENTE', '00001', 'Ref. remesas de cliente');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_COMISIONES', '00001', 1, 'Ref. liquidaciones de comision');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (6, 1, 'REF_COMISIONES', '00001', 'Ref. liquidaciones de comision');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_FACTURAS_PROVEEDOR', '00001', 1, 'Ref. facturas de proveedor');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (7, 1, 'REF_FACTURAS_PROVEEDOR', '00001', 'Ref. facturas de proveedor');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_ALBARANES_DEV_CLIENTE', '00001', 1, 'Ref. ordenes de devolucion de cliente');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (8, 1, 'REF_ALBARANES_DEV_CLIENTE', '00001', 'Ref. ordenes de devolucion de cliente');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_ALBARANES_DEV_PROVEEDOR', '00001', 1, 'Ref. ordenes de devolucion de proveedor');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (9, 1, 'REF_ALBARANES_DEV_PROVEEDOR', '00001', 'Ref. ordenes de devolucion de proveedor');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_REMESAS_PROVEEDOR', '00001', 1, 'Ref. remesas de proveedor');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (10, 1, 'REF_REMESAS_PROVEEDOR', '00001', 'Ref. remesas de proveedor');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_ABONOS_CLIENTE', '00001', 1, 'Ref. abonos de cliente');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (11, 1, 'REF_ABONOS_CLIENTE', '00001', 'Ref. abonos de cliente');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_ABONOS_PROVEEDOR', '00001', 1, 'Ref. abonos de proveedor');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (12, 1, 'REF_ABONOS_PROVEEDOR', '00001', 'Ref. abonos de proveedor');
|
||||||
INSERT INTO REFERENCIAS (CODIGO, VALOR, ID_EMPRESA, DESCRIPCION) VALUES ('REF_PRESUPUESTOS_CLIENTE', '000001', 1, 'Ref. presupuestos de cliente');
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (13, 1, 'REF_PRESUPUESTOS_CLIENTE', '000004', 'Ref. presupuestos de cliente');
|
||||||
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (14, NULL, 'REF_CLIENTES', '00001', 'Ref. clientes');
|
||||||
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (15, NULL, 'REF_PROVEEDORES', '00001', 'Ref. proveedores');
|
||||||
|
INSERT INTO REFERENCIAS (ID, ID_EMPRESA, CODIGO, VALOR, DESCRIPCION) VALUES (16, NULL, 'REF_EMPLEADOS', '000001', 'Ref. empleados');
|
||||||
|
SET GENERATOR GEN_REFERENCIAS_ID TO 17;
|
||||||
COMMIT WORK;
|
COMMIT WORK;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO TIPOS_IVA (ID, REFERENCIA, DESCRIPCION, IVA, RE) VALUES (1, 'IVA16', 'IVA16', 16, 4);
|
INSERT INTO TIPOS_IVA (ID, REFERENCIA, DESCRIPCION, IVA, RE) VALUES (1, 'IVA16', 'IVA16', 16, 4);
|
||||||
INSERT INTO TIPOS_IVA (ID, REFERENCIA, DESCRIPCION, IVA, RE) VALUES (2, 'IVA4', 'IVA4', 4, 0.5);
|
INSERT INTO TIPOS_IVA (ID, REFERENCIA, DESCRIPCION, IVA, RE) VALUES (2, 'IVA4', 'IVA4', 4, 0.5);
|
||||||
INSERT INTO TIPOS_IVA (ID, REFERENCIA, DESCRIPCION, IVA, RE) VALUES (3, 'IVA7', 'IVA7', 7, 1);
|
INSERT INTO TIPOS_IVA (ID, REFERENCIA, DESCRIPCION, IVA, RE) VALUES (3, 'IVA7', 'IVA7', 7, 1);
|
||||||
|
|||||||
@ -9,21 +9,13 @@ const
|
|||||||
{ Data table rules ids
|
{ Data table rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferencia = '{A693E269-BAF7-46A1-84E5-DBC746856BE3}';
|
RID_AlbaranesCliente = '{4C4AED7E-9AD2-4F22-B68E-AD7B8F338052}';
|
||||||
RID_AlbaranesCliente = '{1D19F302-9D09-4E86-9602-98B88C9FF5E7}';
|
RID_AlbaranesCliente_Detalles = '{1F13B20A-918D-41E3-970E-3AC9E0E6BB9B}';
|
||||||
RID_AlbaranesCliente_Detalles = '{DFBF54C4-E8F9-47BA-9920-89709FB21148}';
|
|
||||||
|
|
||||||
{ Data table names }
|
{ Data table names }
|
||||||
nme_DarReferencia = 'DarReferencia';
|
|
||||||
nme_AlbaranesCliente = 'AlbaranesCliente';
|
nme_AlbaranesCliente = 'AlbaranesCliente';
|
||||||
nme_AlbaranesCliente_Detalles = 'AlbaranesCliente_Detalles';
|
nme_AlbaranesCliente_Detalles = 'AlbaranesCliente_Detalles';
|
||||||
|
|
||||||
{ DarReferencia fields }
|
|
||||||
fld_DarReferenciaVALOR = 'VALOR';
|
|
||||||
|
|
||||||
{ DarReferencia field indexes }
|
|
||||||
idx_DarReferenciaVALOR = 0;
|
|
||||||
|
|
||||||
{ AlbaranesCliente fields }
|
{ AlbaranesCliente fields }
|
||||||
fld_AlbaranesClienteID = 'ID';
|
fld_AlbaranesClienteID = 'ID';
|
||||||
fld_AlbaranesClienteID_EMPRESA = 'ID_EMPRESA';
|
fld_AlbaranesClienteID_EMPRESA = 'ID_EMPRESA';
|
||||||
@ -139,44 +131,9 @@ const
|
|||||||
idx_AlbaranesCliente_DetallesREFERENCIA_PROVEEDOR = 13;
|
idx_AlbaranesCliente_DetallesREFERENCIA_PROVEEDOR = 13;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferencia }
|
|
||||||
IDarReferencia = interface(IDAStronglyTypedDataTable)
|
|
||||||
['{15B4231D-DD94-42A2-9AC2-4C32AFB4B267}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String;
|
|
||||||
procedure SetVALORValue(const aValue: String);
|
|
||||||
function GetVALORIsNull: Boolean;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean);
|
|
||||||
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
TDarReferenciaDataTableRules = class(TIntfObjectDADataTableRules, IDarReferencia)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aDataTable: TDADataTable); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IAlbaranesCliente }
|
{ IAlbaranesCliente }
|
||||||
IAlbaranesCliente = interface(IDAStronglyTypedDataTable)
|
IAlbaranesCliente = interface(IDAStronglyTypedDataTable)
|
||||||
['{26F46D95-DBBE-40FD-BB99-EEC4B6EE75CD}']
|
['{CC452DE4-1563-4ECC-B92C-60D8F9E3350A}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -667,7 +624,7 @@ type
|
|||||||
|
|
||||||
{ IAlbaranesCliente_Detalles }
|
{ IAlbaranesCliente_Detalles }
|
||||||
IAlbaranesCliente_Detalles = interface(IDAStronglyTypedDataTable)
|
IAlbaranesCliente_Detalles = interface(IDAStronglyTypedDataTable)
|
||||||
['{C442C7DF-32BE-4A00-8446-3DA2F08508AC}']
|
['{CD3C0BC2-392C-4937-885E-7396FEC8D6CC}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -860,39 +817,6 @@ implementation
|
|||||||
|
|
||||||
uses Variants, uROBinaryHelpers;
|
uses Variants, uROBinaryHelpers;
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
constructor TDarReferenciaDataTableRules.Create(aDataTable: TDADataTable);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaDataTableRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].AsString;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsString := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORIsNull: boolean;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].IsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsVariant := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TAlbaranesClienteDataTableRules }
|
{ TAlbaranesClienteDataTableRules }
|
||||||
constructor TAlbaranesClienteDataTableRules.Create(aDataTable: TDADataTable);
|
constructor TAlbaranesClienteDataTableRules.Create(aDataTable: TDADataTable);
|
||||||
var
|
var
|
||||||
@ -2043,7 +1967,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterDataTableRules(RID_DarReferencia, TDarReferenciaDataTableRules);
|
|
||||||
RegisterDataTableRules(RID_AlbaranesCliente, TAlbaranesClienteDataTableRules);
|
RegisterDataTableRules(RID_AlbaranesCliente, TAlbaranesClienteDataTableRules);
|
||||||
RegisterDataTableRules(RID_AlbaranesCliente_Detalles, TAlbaranesCliente_DetallesDataTableRules);
|
RegisterDataTableRules(RID_AlbaranesCliente_Detalles, TAlbaranesCliente_DetallesDataTableRules);
|
||||||
|
|
||||||
|
|||||||
@ -9,48 +9,13 @@ const
|
|||||||
{ Delta rules ids
|
{ Delta rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferenciaDelta = '{95530CA0-F6C5-439B-ACE3-8DD1B50D65AC}';
|
RID_AlbaranesClienteDelta = '{14AC5B6B-A7CC-4A17-846D-4029E0864BF7}';
|
||||||
RID_AlbaranesClienteDelta = '{9E1A105B-7BE6-4100-BED9-9EB5E4517371}';
|
RID_AlbaranesCliente_DetallesDelta = '{A1C938B1-881C-4020-8257-2103E228E798}';
|
||||||
RID_AlbaranesCliente_DetallesDelta = '{4FD893A0-294F-4ACF-8656-9DC37A524688}';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferenciaDelta }
|
|
||||||
IDarReferenciaDelta = interface(IDarReferencia)
|
|
||||||
['{95530CA0-F6C5-439B-ACE3-8DD1B50D65AC}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetOldVALORValue : String;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
TDarReferenciaBusinessProcessorRules = class(TDABusinessProcessorRules, IDarReferencia, IDarReferenciaDelta)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
function GetOldVALORValue: String; virtual;
|
|
||||||
function GetOldVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR : String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull : Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
property OldVALORIsNull : Boolean read GetOldVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aBusinessProcessor: TDABusinessProcessor); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IAlbaranesClienteDelta }
|
{ IAlbaranesClienteDelta }
|
||||||
IAlbaranesClienteDelta = interface(IAlbaranesCliente)
|
IAlbaranesClienteDelta = interface(IAlbaranesCliente)
|
||||||
['{9E1A105B-7BE6-4100-BED9-9EB5E4517371}']
|
['{14AC5B6B-A7CC-4A17-846D-4029E0864BF7}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_EMPRESAValue : Integer;
|
function GetOldID_EMPRESAValue : Integer;
|
||||||
@ -542,7 +507,7 @@ type
|
|||||||
|
|
||||||
{ IAlbaranesCliente_DetallesDelta }
|
{ IAlbaranesCliente_DetallesDelta }
|
||||||
IAlbaranesCliente_DetallesDelta = interface(IAlbaranesCliente_Detalles)
|
IAlbaranesCliente_DetallesDelta = interface(IAlbaranesCliente_Detalles)
|
||||||
['{4FD893A0-294F-4ACF-8656-9DC37A524688}']
|
['{A1C938B1-881C-4020-8257-2103E228E798}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_ALBARANValue : Integer;
|
function GetOldID_ALBARANValue : Integer;
|
||||||
@ -735,49 +700,6 @@ implementation
|
|||||||
uses
|
uses
|
||||||
Variants, uROBinaryHelpers, uDAInterfaces;
|
Variants, uROBinaryHelpers, uDAInterfaces;
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
constructor TDarReferenciaBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaBusinessProcessorRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TAlbaranesClienteBusinessProcessorRules }
|
{ TAlbaranesClienteBusinessProcessorRules }
|
||||||
constructor TAlbaranesClienteBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
constructor TAlbaranesClienteBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
||||||
var
|
var
|
||||||
@ -2460,7 +2382,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(RID_DarReferenciaDelta, TDarReferenciaBusinessProcessorRules);
|
|
||||||
RegisterBusinessProcessorRules(RID_AlbaranesClienteDelta, TAlbaranesClienteBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_AlbaranesClienteDelta, TAlbaranesClienteBusinessProcessorRules);
|
||||||
RegisterBusinessProcessorRules(RID_AlbaranesCliente_DetallesDelta, TAlbaranesCliente_DetallesBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_AlbaranesCliente_DetallesDelta, TAlbaranesCliente_DetallesBusinessProcessorRules);
|
||||||
|
|
||||||
|
|||||||
@ -8,73 +8,110 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
BIZ_SERVER_ALBARAN_CLIENTE = 'Server.AlbaranCliente';
|
BIZ_SERVER_ALBARAN_CLIENTE = 'Server.AlbaranCliente';
|
||||||
REF_ALBARANES_CLIENTE = 'REF_ALBARANES_CLIENTE';
|
|
||||||
REF_ALBARANES_DEV_CLIENTE = 'REF_ALBARANES_DEV_CLIENTE';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TBizAlbaranClienteServer = class(TAlbaranesClienteBusinessProcessorRules)
|
TBizAlbaranClienteServer = class(TAlbaranesClienteBusinessProcessorRules)
|
||||||
|
private
|
||||||
|
FReferenciaAutomatica : Boolean;
|
||||||
|
function DarReferencia : String;
|
||||||
|
function IncrementarReferencia : Boolean;
|
||||||
protected
|
protected
|
||||||
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
|
||||||
|
const aDelta: IDADelta); override;
|
||||||
|
procedure AfterProcessChange(Sender: TDABusinessProcessor;
|
||||||
|
aChange: TDADeltaChange; Processed: Boolean;
|
||||||
|
var CanRemoveFromDelta: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
||||||
schAlbaranesClienteClient_Intf;
|
schAlbaranesClienteClient_Intf, srvReferencias_Impl, JclStrings;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_ALBARANES_CLIENTE = 'REF_ALBARANES_CLIENTE';
|
||||||
|
REF_ALBARANES_DEV_CLIENTE = 'REF_ALBARANES_DEV_CLIENTE';
|
||||||
|
|
||||||
{ TBizAlbaranClienteServer }
|
{ TBizAlbaranClienteServer }
|
||||||
|
|
||||||
procedure TBizAlbaranClienteServer.BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
procedure TBizAlbaranClienteServer.AfterProcessChange(
|
||||||
var
|
Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
|
||||||
ASchema : TDASchema;
|
var CanRemoveFromDelta: Boolean);
|
||||||
ACurrentConn : IDAConnection;
|
|
||||||
dsData: IDADataset;
|
|
||||||
Empresa : Variant;
|
|
||||||
CodigoReferencia: String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
{ Por defecto, no es necesario mantener los deltas una vez
|
||||||
|
procesados los cambios. }
|
||||||
|
CanRemoveFromDelta := True;
|
||||||
|
|
||||||
|
case aChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferencia;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
{ En este caso no debemos quitar los deltas porque
|
||||||
|
el cliente tiene que enterarse de la referencia que
|
||||||
|
ha rellenado el servidor. }
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBizAlbaranClienteServer.BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
|
||||||
case Sender.CurrentChange.ChangeType of
|
case Sender.CurrentChange.ChangeType of
|
||||||
ctInsert, ctUpdate: begin
|
ctInsert, ctUpdate: begin
|
||||||
//Si la referencia no ha sido asignada le asignamos una nosotros
|
//Si la referencia no ha sido asignada le asignamos una nosotros
|
||||||
if (VarIsNull(Sender.CurrentChange.NewValueByName[fld_AlbaranesClienteREFERENCIA]))
|
if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then
|
||||||
or (VarToStr(Sender.CurrentChange.NewValueByName[fld_AlbaranesClienteREFERENCIA]) = '') then
|
|
||||||
begin
|
begin
|
||||||
ASchema := BusinessProcessor.Schema;
|
FReferenciaAutomatica := True;
|
||||||
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
|
REFERENCIA := DarReferencia;
|
||||||
|
|
||||||
try
|
|
||||||
//Siempre va a estar rellena
|
|
||||||
Empresa := Sender.CurrentChange.NewValueByName[fld_AlbaranesClienteID_EMPRESA];
|
|
||||||
if (Sender.CurrentChange.NewValueByName[fld_AlbaranesClienteIMPORTE_TOTAL] < 0) then
|
|
||||||
CodigoReferencia := REF_ALBARANES_DEV_CLIENTE
|
|
||||||
else
|
|
||||||
CodigoReferencia := REF_ALBARANES_CLIENTE;
|
|
||||||
|
|
||||||
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [CodigoReferencia, Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('No existe la tabla REFERENCIAS');
|
|
||||||
end;
|
|
||||||
|
|
||||||
dsData.Active := True;
|
|
||||||
|
|
||||||
if dsData.IsEmpty then
|
|
||||||
RaiseError('NO HAY REFERENCIA ' + CodigoReferencia + ' DECLARADA EN TABLA REFERENCIAS');
|
|
||||||
|
|
||||||
REFERENCIA := dsData.FieldByName(fld_DarReferenciaVALOR).AsString;
|
|
||||||
|
|
||||||
try
|
|
||||||
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'EMPRESA'], [CodigoReferencia, DarReferenciaSiguiente(REFERENCIA), Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla');
|
|
||||||
end;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizAlbaranClienteServer.DarReferencia: String;
|
||||||
|
var
|
||||||
|
ACodigoReferencia : String;
|
||||||
|
begin
|
||||||
|
if (IMPORTE_TOTAL < 0) then
|
||||||
|
ACodigoReferencia := REF_ALBARANES_DEV_CLIENTE
|
||||||
|
else
|
||||||
|
ACodigoReferencia := REF_ALBARANES_CLIENTE;
|
||||||
|
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(ACodigoReferencia, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBizAlbaranClienteServer.IncrementarReferencia: Boolean;
|
||||||
|
var
|
||||||
|
ACodigoReferencia : String;
|
||||||
|
begin
|
||||||
|
if (IMPORTE_TOTAL < 0) then
|
||||||
|
ACodigoReferencia := REF_ALBARANES_DEV_CLIENTE
|
||||||
|
else
|
||||||
|
ACodigoReferencia := REF_ALBARANES_CLIENTE;
|
||||||
|
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(ACodigoReferencia,
|
||||||
|
Self.REFERENCIA, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(BIZ_SERVER_ALBARAN_CLIENTE, TBizAlbaranClienteServer);
|
RegisterBusinessProcessorRules(BIZ_SERVER_ALBARAN_CLIENTE, TBizAlbaranClienteServer);
|
||||||
|
|
||||||
|
|||||||
@ -14,40 +14,6 @@ object srvAlbaranesCliente: TsrvAlbaranesCliente
|
|||||||
ConnectionManager = dmServer.ConnectionManager
|
ConnectionManager = dmServer.ConnectionManager
|
||||||
DataDictionary = DADataDictionary
|
DataDictionary = DADataDictionary
|
||||||
Datasets = <
|
Datasets = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'SELECT'#10' VALOR'#10'FROM'#10' REFERENCIAS'#10'WHERE'#10' CODIGO = :COD' +
|
|
||||||
'IGO'#10'AND ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <
|
|
||||||
item
|
|
||||||
DatasetField = 'VALOR'
|
|
||||||
TableField = 'VALOR'
|
|
||||||
end>
|
|
||||||
end>
|
|
||||||
Name = 'DarReferencia'
|
|
||||||
Fields = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
DataType = datString
|
|
||||||
Size = 255
|
|
||||||
end>
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <>
|
Params = <>
|
||||||
Statements = <
|
Statements = <
|
||||||
@ -591,32 +557,6 @@ object srvAlbaranesCliente: TsrvAlbaranesCliente
|
|||||||
JoinDataTables = <>
|
JoinDataTables = <>
|
||||||
UnionDataTables = <>
|
UnionDataTables = <>
|
||||||
Commands = <
|
Commands = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'UPDATE REFERENCIAS SET'#10' VALOR = :VALOR'#10'WHERE CODIGO = :COD' +
|
|
||||||
'IGO AND'#10' ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <>
|
|
||||||
end>
|
|
||||||
Name = 'ModificarReferencia'
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <
|
Params = <
|
||||||
item
|
item
|
||||||
|
|||||||
@ -9,21 +9,13 @@ const
|
|||||||
{ Data table rules ids
|
{ Data table rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferencia = '{E264DAAA-A65A-4F97-8399-054CD6715754}';
|
RID_AlbaranesProveedor = '{B3C84E57-4911-483C-BF95-BC529DBB583C}';
|
||||||
RID_AlbaranesProveedor = '{8070DE55-5BC2-4DCA-B26F-B6E77353CD13}';
|
RID_AlbaranesProveedor_Detalles = '{F665A12E-A0DC-4E29-A620-593A4192A81D}';
|
||||||
RID_AlbaranesProveedor_Detalles = '{B5916447-B176-439A-8E99-A6CDA1527B86}';
|
|
||||||
|
|
||||||
{ Data table names }
|
{ Data table names }
|
||||||
nme_DarReferencia = 'DarReferencia';
|
|
||||||
nme_AlbaranesProveedor = 'AlbaranesProveedor';
|
nme_AlbaranesProveedor = 'AlbaranesProveedor';
|
||||||
nme_AlbaranesProveedor_Detalles = 'AlbaranesProveedor_Detalles';
|
nme_AlbaranesProveedor_Detalles = 'AlbaranesProveedor_Detalles';
|
||||||
|
|
||||||
{ DarReferencia fields }
|
|
||||||
fld_DarReferenciaVALOR = 'VALOR';
|
|
||||||
|
|
||||||
{ DarReferencia field indexes }
|
|
||||||
idx_DarReferenciaVALOR = 0;
|
|
||||||
|
|
||||||
{ AlbaranesProveedor fields }
|
{ AlbaranesProveedor fields }
|
||||||
fld_AlbaranesProveedorID = 'ID';
|
fld_AlbaranesProveedorID = 'ID';
|
||||||
fld_AlbaranesProveedorID_EMPRESA = 'ID_EMPRESA';
|
fld_AlbaranesProveedorID_EMPRESA = 'ID_EMPRESA';
|
||||||
@ -133,44 +125,9 @@ const
|
|||||||
idx_AlbaranesProveedor_DetallesREFERENCIA_PROVEEDOR = 13;
|
idx_AlbaranesProveedor_DetallesREFERENCIA_PROVEEDOR = 13;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferencia }
|
|
||||||
IDarReferencia = interface(IDAStronglyTypedDataTable)
|
|
||||||
['{87BCEB3E-3FAF-44FF-A992-70B549FF79CE}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String;
|
|
||||||
procedure SetVALORValue(const aValue: String);
|
|
||||||
function GetVALORIsNull: Boolean;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean);
|
|
||||||
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
TDarReferenciaDataTableRules = class(TIntfObjectDADataTableRules, IDarReferencia)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aDataTable: TDADataTable); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IAlbaranesProveedor }
|
{ IAlbaranesProveedor }
|
||||||
IAlbaranesProveedor = interface(IDAStronglyTypedDataTable)
|
IAlbaranesProveedor = interface(IDAStronglyTypedDataTable)
|
||||||
['{91E3DC89-DDB4-4727-88A3-1931B49B7F08}']
|
['{E60D9CCD-626B-4506-B2ED-69DC12E34AC7}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -625,7 +582,7 @@ type
|
|||||||
|
|
||||||
{ IAlbaranesProveedor_Detalles }
|
{ IAlbaranesProveedor_Detalles }
|
||||||
IAlbaranesProveedor_Detalles = interface(IDAStronglyTypedDataTable)
|
IAlbaranesProveedor_Detalles = interface(IDAStronglyTypedDataTable)
|
||||||
['{A644C742-27E7-449C-9A6B-ED24143E13CD}']
|
['{EEB82A6C-B78D-4D5E-A152-218B7BC3E9DF}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -818,39 +775,6 @@ implementation
|
|||||||
|
|
||||||
uses Variants, uROBinaryHelpers;
|
uses Variants, uROBinaryHelpers;
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
constructor TDarReferenciaDataTableRules.Create(aDataTable: TDADataTable);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaDataTableRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].AsString;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsString := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORIsNull: boolean;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].IsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsVariant := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TAlbaranesProveedorDataTableRules }
|
{ TAlbaranesProveedorDataTableRules }
|
||||||
constructor TAlbaranesProveedorDataTableRules.Create(aDataTable: TDADataTable);
|
constructor TAlbaranesProveedorDataTableRules.Create(aDataTable: TDADataTable);
|
||||||
var
|
var
|
||||||
@ -1938,7 +1862,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterDataTableRules(RID_DarReferencia, TDarReferenciaDataTableRules);
|
|
||||||
RegisterDataTableRules(RID_AlbaranesProveedor, TAlbaranesProveedorDataTableRules);
|
RegisterDataTableRules(RID_AlbaranesProveedor, TAlbaranesProveedorDataTableRules);
|
||||||
RegisterDataTableRules(RID_AlbaranesProveedor_Detalles, TAlbaranesProveedor_DetallesDataTableRules);
|
RegisterDataTableRules(RID_AlbaranesProveedor_Detalles, TAlbaranesProveedor_DetallesDataTableRules);
|
||||||
|
|
||||||
|
|||||||
@ -9,48 +9,13 @@ const
|
|||||||
{ Delta rules ids
|
{ Delta rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferenciaDelta = '{AD9EC61F-92A8-4757-A729-430A9C0F1014}';
|
RID_AlbaranesProveedorDelta = '{262D0052-9D3B-419A-B2F4-B52A68D8D3DB}';
|
||||||
RID_AlbaranesProveedorDelta = '{6120285E-A519-4B85-96C3-9568FD81A17F}';
|
RID_AlbaranesProveedor_DetallesDelta = '{A33E831D-4454-40E5-BBBD-B367628D4A88}';
|
||||||
RID_AlbaranesProveedor_DetallesDelta = '{CEDDEB44-9AE4-468F-A241-3235B7D100D6}';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferenciaDelta }
|
|
||||||
IDarReferenciaDelta = interface(IDarReferencia)
|
|
||||||
['{AD9EC61F-92A8-4757-A729-430A9C0F1014}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetOldVALORValue : String;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
TDarReferenciaBusinessProcessorRules = class(TDABusinessProcessorRules, IDarReferencia, IDarReferenciaDelta)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
function GetOldVALORValue: String; virtual;
|
|
||||||
function GetOldVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR : String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull : Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
property OldVALORIsNull : Boolean read GetOldVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aBusinessProcessor: TDABusinessProcessor); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IAlbaranesProveedorDelta }
|
{ IAlbaranesProveedorDelta }
|
||||||
IAlbaranesProveedorDelta = interface(IAlbaranesProveedor)
|
IAlbaranesProveedorDelta = interface(IAlbaranesProveedor)
|
||||||
['{6120285E-A519-4B85-96C3-9568FD81A17F}']
|
['{262D0052-9D3B-419A-B2F4-B52A68D8D3DB}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_EMPRESAValue : Integer;
|
function GetOldID_EMPRESAValue : Integer;
|
||||||
@ -506,7 +471,7 @@ type
|
|||||||
|
|
||||||
{ IAlbaranesProveedor_DetallesDelta }
|
{ IAlbaranesProveedor_DetallesDelta }
|
||||||
IAlbaranesProveedor_DetallesDelta = interface(IAlbaranesProveedor_Detalles)
|
IAlbaranesProveedor_DetallesDelta = interface(IAlbaranesProveedor_Detalles)
|
||||||
['{CEDDEB44-9AE4-468F-A241-3235B7D100D6}']
|
['{A33E831D-4454-40E5-BBBD-B367628D4A88}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_ALBARANValue : Integer;
|
function GetOldID_ALBARANValue : Integer;
|
||||||
@ -699,49 +664,6 @@ implementation
|
|||||||
uses
|
uses
|
||||||
Variants, uROBinaryHelpers, uDAInterfaces;
|
Variants, uROBinaryHelpers, uDAInterfaces;
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
constructor TDarReferenciaBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaBusinessProcessorRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TAlbaranesProveedorBusinessProcessorRules }
|
{ TAlbaranesProveedorBusinessProcessorRules }
|
||||||
constructor TAlbaranesProveedorBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
constructor TAlbaranesProveedorBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
||||||
var
|
var
|
||||||
@ -2331,7 +2253,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(RID_DarReferenciaDelta, TDarReferenciaBusinessProcessorRules);
|
|
||||||
RegisterBusinessProcessorRules(RID_AlbaranesProveedorDelta, TAlbaranesProveedorBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_AlbaranesProveedorDelta, TAlbaranesProveedorBusinessProcessorRules);
|
||||||
RegisterBusinessProcessorRules(RID_AlbaranesProveedor_DetallesDelta, TAlbaranesProveedor_DetallesBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_AlbaranesProveedor_DetallesDelta, TAlbaranesProveedor_DetallesBusinessProcessorRules);
|
||||||
|
|
||||||
|
|||||||
@ -8,73 +8,110 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
BIZ_SERVER_ALBARAN_PROVEEDOR = 'Server.AlbaranProveedor';
|
BIZ_SERVER_ALBARAN_PROVEEDOR = 'Server.AlbaranProveedor';
|
||||||
REF_ALBARANES_PROVEEDOR = 'REF_ALBARANES_PROVEEDOR';
|
|
||||||
REF_ALBARANES_DEV_PROVEEDOR = 'REF_ALBARANES_DEV_PROVEEDOR';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TBizAlbaranProveedorServer = class(TFacturasClienteBusinessProcessorRules)
|
TBizAlbaranProveedorServer = class(TFacturasClienteBusinessProcessorRules)
|
||||||
|
private
|
||||||
|
FReferenciaAutomatica : Boolean;
|
||||||
|
function DarReferencia : String;
|
||||||
|
function IncrementarReferencia : Boolean;
|
||||||
protected
|
protected
|
||||||
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
|
||||||
|
const aDelta: IDADelta); override;
|
||||||
|
procedure AfterProcessChange(Sender: TDABusinessProcessor;
|
||||||
|
aChange: TDADeltaChange; Processed: Boolean;
|
||||||
|
var CanRemoveFromDelta: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Dialogs, SysUtils, Variants, uDataModuleServer, uDAClasses, DARemoteService_Impl,
|
Dialogs, SysUtils, Variants, uDataModuleServer, uDAClasses,
|
||||||
schAlbaranesProveedorClient_Intf, uBusinessUtils, uReferenciasUtils, uROClasses;
|
schAlbaranesProveedorClient_Intf, uBusinessUtils, uROClasses,
|
||||||
|
srvReferencias_Impl;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_ALBARANES_PROVEEDOR = 'REF_ALBARANES_PROVEEDOR';
|
||||||
|
REF_ALBARANES_DEV_PROVEEDOR = 'REF_ALBARANES_DEV_PROVEEDOR';
|
||||||
|
|
||||||
|
|
||||||
{ TBizFacturasClienteServer }
|
{ TBizFacturasClienteServer }
|
||||||
|
|
||||||
procedure TBizAlbaranProveedorServer.BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
procedure TBizAlbaranProveedorServer.AfterProcessChange(
|
||||||
var
|
Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
|
||||||
ASchema : TDASchema;
|
var CanRemoveFromDelta: Boolean);
|
||||||
ACurrentConn : IDAConnection;
|
|
||||||
dsData: IDADataset;
|
|
||||||
Empresa : Variant;
|
|
||||||
CodigoReferencia: String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
{ Por defecto, no es necesario mantener los deltas una vez
|
||||||
|
procesados los cambios. }
|
||||||
|
CanRemoveFromDelta := True;
|
||||||
|
|
||||||
|
case aChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferencia;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
{ En este caso no debemos quitar los deltas porque
|
||||||
|
el cliente tiene que enterarse de la referencia que
|
||||||
|
ha rellenado el servidor. }
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBizAlbaranProveedorServer.BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
||||||
|
begin
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
|
||||||
case Sender.CurrentChange.ChangeType of
|
case Sender.CurrentChange.ChangeType of
|
||||||
ctInsert, ctUpdate: begin
|
ctInsert, ctUpdate: begin
|
||||||
//Si la referencia no ha sido asignada le asignamos una nosotros
|
//Si la referencia no ha sido asignada le asignamos una nosotros
|
||||||
if (VarIsNull(Sender.CurrentChange.NewValueByName[fld_AlbaranesProveedorREFERENCIA]))
|
if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then
|
||||||
or (VarToStr(Sender.CurrentChange.NewValueByName[fld_AlbaranesProveedorREFERENCIA]) = '') then
|
|
||||||
begin
|
begin
|
||||||
ASchema := BusinessProcessor.Schema;
|
FReferenciaAutomatica := True;
|
||||||
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
|
REFERENCIA := DarReferencia;
|
||||||
|
|
||||||
try
|
|
||||||
//Siempre va a estar rellena
|
|
||||||
Empresa := Sender.CurrentChange.NewValueByName[fld_AlbaranesProveedorID_EMPRESA];
|
|
||||||
if Sender.CurrentChange.NewValueByName[fld_AlbaranesProveedorIMPORTE_TOTAL] < 0 then
|
|
||||||
CodigoReferencia := REF_ALBARANES_DEV_PROVEEDOR
|
|
||||||
else
|
|
||||||
CodigoReferencia := REF_ALBARANES_PROVEEDOR;
|
|
||||||
|
|
||||||
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [CodigoReferencia, Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('No existe la tabla REFERENCIAS');
|
|
||||||
end;
|
|
||||||
|
|
||||||
dsData.Active := True;
|
|
||||||
|
|
||||||
if dsData.IsEmpty then
|
|
||||||
RaiseError('NO HAY REFERENCIA ' + CodigoReferencia + ' DECLARADA EN TABLA REFERENCIAS');
|
|
||||||
|
|
||||||
REFERENCIA := dsData.FieldByName(fld_DarReferenciaVALOR).AsString;
|
|
||||||
|
|
||||||
try
|
|
||||||
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'EMPRESA'], [CodigoReferencia, DarReferenciaSiguiente(REFERENCIA), Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla');
|
|
||||||
end;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizAlbaranProveedorServer.DarReferencia: String;
|
||||||
|
var
|
||||||
|
ACodigoReferencia : String;
|
||||||
|
begin
|
||||||
|
if (IMPORTE_TOTAL < 0) then
|
||||||
|
ACodigoReferencia := REF_ALBARANES_DEV_PROVEEDOR
|
||||||
|
else
|
||||||
|
ACodigoReferencia := REF_ALBARANES_PROVEEDOR;
|
||||||
|
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(ACodigoReferencia, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBizAlbaranProveedorServer.IncrementarReferencia: Boolean;
|
||||||
|
var
|
||||||
|
ACodigoReferencia : String;
|
||||||
|
begin
|
||||||
|
if (IMPORTE_TOTAL < 0) then
|
||||||
|
ACodigoReferencia := REF_ALBARANES_DEV_PROVEEDOR
|
||||||
|
else
|
||||||
|
ACodigoReferencia := REF_ALBARANES_PROVEEDOR;
|
||||||
|
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(ACodigoReferencia,
|
||||||
|
Self.REFERENCIA, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(BIZ_SERVER_ALBARAN_PROVEEDOR, TBizAlbaranProveedorServer);
|
RegisterBusinessProcessorRules(BIZ_SERVER_ALBARAN_PROVEEDOR, TBizAlbaranProveedorServer);
|
||||||
|
|
||||||
|
|||||||
@ -14,40 +14,6 @@ object srvAlbaranesProveedor: TsrvAlbaranesProveedor
|
|||||||
ConnectionManager = dmServer.ConnectionManager
|
ConnectionManager = dmServer.ConnectionManager
|
||||||
DataDictionary = DADataDictionary
|
DataDictionary = DADataDictionary
|
||||||
Datasets = <
|
Datasets = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'SELECT'#10' VALOR'#10'FROM'#10' REFERENCIAS'#10'WHERE'#10' CODIGO = :COD' +
|
|
||||||
'IGO'#10'AND ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <
|
|
||||||
item
|
|
||||||
DatasetField = 'VALOR'
|
|
||||||
TableField = 'VALOR'
|
|
||||||
end>
|
|
||||||
end>
|
|
||||||
Name = 'DarReferencia'
|
|
||||||
Fields = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
DataType = datString
|
|
||||||
Size = 255
|
|
||||||
end>
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <>
|
Params = <>
|
||||||
Statements = <
|
Statements = <
|
||||||
@ -565,32 +531,6 @@ object srvAlbaranesProveedor: TsrvAlbaranesProveedor
|
|||||||
JoinDataTables = <>
|
JoinDataTables = <>
|
||||||
UnionDataTables = <>
|
UnionDataTables = <>
|
||||||
Commands = <
|
Commands = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'UPDATE REFERENCIAS SET'#10' VALOR = :VALOR'#10'WHERE CODIGO = :COD' +
|
|
||||||
'IGO AND'#10' ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <>
|
|
||||||
end>
|
|
||||||
Name = 'ModificarReferencia'
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <
|
Params = <
|
||||||
item
|
item
|
||||||
|
|||||||
@ -12,6 +12,9 @@ const
|
|||||||
type
|
type
|
||||||
TBizClienteServer = class(TBizContactosServer)
|
TBizClienteServer = class(TBizContactosServer)
|
||||||
protected
|
protected
|
||||||
|
function DarReferenciaContacto : String; override;
|
||||||
|
function IncrementarReferenciaContacto : Boolean; override;
|
||||||
|
|
||||||
procedure Insert_Datos_Contacto(aChange: TDADeltaChange); override;
|
procedure Insert_Datos_Contacto(aChange: TDADeltaChange); override;
|
||||||
procedure Update_Datos_Contacto(aChange: TDADeltaChange); override;
|
procedure Update_Datos_Contacto(aChange: TDADeltaChange); override;
|
||||||
procedure Delete_Datos_Contacto(aChange: TDADeltaChange); override;
|
procedure Delete_Datos_Contacto(aChange: TDADeltaChange); override;
|
||||||
@ -20,11 +23,25 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
uDataModuleServer, uDAClasses,
|
uDataModuleServer, uDAClasses,
|
||||||
schContactosClient_Intf, uBusinessUtils;
|
schContactosClient_Intf, uBusinessUtils, srvReferencias_Impl;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_CLIENTES = 'REF_CLIENTES';
|
||||||
|
|
||||||
|
|
||||||
{ TBizClienteServer }
|
{ TBizClienteServer }
|
||||||
|
|
||||||
|
function TBizClienteServer.DarReferenciaContacto: String;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(REF_CLIENTES)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBizClienteServer.Delete_Datos_Contacto(aChange: TDADeltaChange);
|
procedure TBizClienteServer.Delete_Datos_Contacto(aChange: TDADeltaChange);
|
||||||
var
|
var
|
||||||
ASchema : TDASchema;
|
ASchema : TDASchema;
|
||||||
@ -48,6 +65,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizClienteServer.IncrementarReferenciaContacto: Boolean;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(REF_CLIENTES, Self.REFERENCIA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBizClienteServer.Insert_Datos_Contacto(aChange: TDADeltaChange);
|
procedure TBizClienteServer.Insert_Datos_Contacto(aChange: TDADeltaChange);
|
||||||
var
|
var
|
||||||
ASchema : TDASchema;
|
ASchema : TDASchema;
|
||||||
|
|||||||
@ -11,7 +11,12 @@ const
|
|||||||
|
|
||||||
type
|
type
|
||||||
TBizContactosServer = class(TContactosBusinessProcessorRules)
|
TBizContactosServer = class(TContactosBusinessProcessorRules)
|
||||||
|
private
|
||||||
|
FReferenciaAutomatica : Boolean;
|
||||||
protected
|
protected
|
||||||
|
function DarReferenciaContacto : String; virtual; abstract;
|
||||||
|
function IncrementarReferenciaContacto : Boolean; virtual; abstract;
|
||||||
|
|
||||||
procedure Insert_Datos_Contacto(aChange: TDADeltaChange); virtual;
|
procedure Insert_Datos_Contacto(aChange: TDADeltaChange); virtual;
|
||||||
procedure Update_Datos_Contacto(aChange: TDADeltaChange); virtual;
|
procedure Update_Datos_Contacto(aChange: TDADeltaChange); virtual;
|
||||||
procedure Delete_Datos_Contacto(aChange: TDADeltaChange); virtual;
|
procedure Delete_Datos_Contacto(aChange: TDADeltaChange); virtual;
|
||||||
@ -20,6 +25,9 @@ type
|
|||||||
procedure Update_Categoria_Contacto(aChange: TDADeltaChange); virtual;
|
procedure Update_Categoria_Contacto(aChange: TDADeltaChange); virtual;
|
||||||
procedure Delete_Categoria_Contacto(aChange: TDADeltaChange); virtual;
|
procedure Delete_Categoria_Contacto(aChange: TDADeltaChange); virtual;
|
||||||
|
|
||||||
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
|
||||||
|
const aDelta: IDADelta); override;
|
||||||
|
|
||||||
procedure AfterProcessChange(Sender: TDABusinessProcessor;
|
procedure AfterProcessChange(Sender: TDABusinessProcessor;
|
||||||
aChange: TDADeltaChange; Processed: Boolean;
|
aChange: TDADeltaChange; Processed: Boolean;
|
||||||
var CanRemoveFromDelta: Boolean); override;
|
var CanRemoveFromDelta: Boolean); override;
|
||||||
@ -28,14 +36,13 @@ type
|
|||||||
aChangeType: TDAChangeType; aChange: TDADeltaChange;
|
aChangeType: TDAChangeType; aChange: TDADeltaChange;
|
||||||
const aCommand: IDASQLCommand; var CanRemoveFromDelta: Boolean;
|
const aCommand: IDASQLCommand; var CanRemoveFromDelta: Boolean;
|
||||||
Error: Exception); override;
|
Error: Exception); override;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Dialogs, uDataModuleServer, uDAClasses,
|
Dialogs, uDataModuleServer, uDAClasses, Variants,
|
||||||
schContactosClient_Intf, uBusinessUtils;
|
schContactosClient_Intf, uBusinessUtils, srvReferencias_Impl;
|
||||||
|
|
||||||
{ TBizContactosServer }
|
{ TBizContactosServer }
|
||||||
|
|
||||||
@ -43,15 +50,36 @@ procedure TBizContactosServer.AfterProcessChange(Sender: TDABusinessProcessor;
|
|||||||
aChange: TDADeltaChange; Processed: Boolean; var CanRemoveFromDelta: Boolean);
|
aChange: TDADeltaChange; Processed: Boolean; var CanRemoveFromDelta: Boolean);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
{ Por defecto, no es necesario mantener los deltas una vez
|
||||||
|
procesados los cambios. }
|
||||||
|
CanRemoveFromDelta := True;
|
||||||
|
|
||||||
case aChange.ChangeType of
|
case aChange.ChangeType of
|
||||||
ctInsert: begin
|
ctInsert: begin
|
||||||
Insert_Categoria_Contacto(aChange);
|
Insert_Categoria_Contacto(aChange);
|
||||||
Insert_Datos_Contacto(aChange);
|
Insert_Datos_Contacto(aChange);
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferenciaContacto;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
{ En este caso no debemos quitar los deltas porque
|
||||||
|
el cliente tiene que enterarse de la referencia que
|
||||||
|
ha rellenado el servidor. }
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
ctUpdate: begin
|
ctUpdate: begin
|
||||||
Update_Categoria_Contacto(aChange);
|
Update_Categoria_Contacto(aChange);
|
||||||
Update_Datos_Contacto(aChange);
|
Update_Datos_Contacto(aChange);
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferenciaContacto;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
{ En este caso no debemos quitar los deltas porque
|
||||||
|
el cliente tiene que enterarse de la referencia que
|
||||||
|
ha rellenado el servidor. }
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
ctDelete: begin
|
ctDelete: begin
|
||||||
Delete_Categoria_Contacto(aChange);
|
Delete_Categoria_Contacto(aChange);
|
||||||
@ -59,7 +87,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
CanRemoveFromDelta := True;
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBizContactosServer.BeforeProcessDelta(Sender: TDABusinessProcessor;
|
||||||
|
const aDelta: IDADelta);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
case Sender.CurrentChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
// Si la referencia no ha sido asignada le asignamos una nosotros
|
||||||
|
if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then
|
||||||
|
begin
|
||||||
|
FReferenciaAutomatica := True;
|
||||||
|
REFERENCIA := DarReferenciaContacto;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBizContactosServer.Delete_Categoria_Contacto(
|
procedure TBizContactosServer.Delete_Categoria_Contacto(
|
||||||
|
|||||||
@ -12,6 +12,9 @@ const
|
|||||||
type
|
type
|
||||||
TBizEmpleadoServer = class(TBizContactosServer)
|
TBizEmpleadoServer = class(TBizContactosServer)
|
||||||
protected
|
protected
|
||||||
|
function DarReferenciaContacto : String; override;
|
||||||
|
function IncrementarReferenciaContacto : Boolean; override;
|
||||||
|
|
||||||
procedure Insert_Datos_Contacto(aChange: TDADeltaChange); override;
|
procedure Insert_Datos_Contacto(aChange: TDADeltaChange); override;
|
||||||
procedure Update_Datos_Contacto(aChange: TDADeltaChange); override;
|
procedure Update_Datos_Contacto(aChange: TDADeltaChange); override;
|
||||||
procedure Delete_Datos_Contacto(aChange: TDADeltaChange); override;
|
procedure Delete_Datos_Contacto(aChange: TDADeltaChange); override;
|
||||||
@ -21,10 +24,23 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
uDataModuleServer, uDAClasses,
|
uDataModuleServer, uDAClasses,
|
||||||
schContactosClient_Intf, uBusinessUtils;
|
schContactosClient_Intf, uBusinessUtils, srvReferencias_Impl;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_EMPLEADOS = 'REF_EMPLEADOS';
|
||||||
|
|
||||||
{ TBizEmpleadoServer }
|
{ TBizEmpleadoServer }
|
||||||
|
|
||||||
|
function TBizEmpleadoServer.DarReferenciaContacto: String;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(REF_EMPLEADOS)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBizEmpleadoServer.Delete_Datos_Contacto(aChange: TDADeltaChange);
|
procedure TBizEmpleadoServer.Delete_Datos_Contacto(aChange: TDADeltaChange);
|
||||||
var
|
var
|
||||||
ASchema : TDASchema;
|
ASchema : TDASchema;
|
||||||
@ -48,6 +64,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizEmpleadoServer.IncrementarReferenciaContacto: Boolean;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(REF_EMPLEADOS, Self.REFERENCIA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBizEmpleadoServer.Insert_Datos_Contacto(aChange: TDADeltaChange);
|
procedure TBizEmpleadoServer.Insert_Datos_Contacto(aChange: TDADeltaChange);
|
||||||
var
|
var
|
||||||
ASchema : TDASchema;
|
ASchema : TDASchema;
|
||||||
|
|||||||
@ -12,6 +12,9 @@ const
|
|||||||
type
|
type
|
||||||
TBizProveedorServer = class(TBizContactosServer)
|
TBizProveedorServer = class(TBizContactosServer)
|
||||||
protected
|
protected
|
||||||
|
function DarReferenciaContacto : String; override;
|
||||||
|
function IncrementarReferenciaContacto : Boolean; override;
|
||||||
|
|
||||||
procedure Insert_Datos_Contacto(aChange: TDADeltaChange); override;
|
procedure Insert_Datos_Contacto(aChange: TDADeltaChange); override;
|
||||||
procedure Update_Datos_Contacto(aChange: TDADeltaChange); override;
|
procedure Update_Datos_Contacto(aChange: TDADeltaChange); override;
|
||||||
procedure Delete_Datos_Contacto(aChange: TDADeltaChange); override;
|
procedure Delete_Datos_Contacto(aChange: TDADeltaChange); override;
|
||||||
@ -21,10 +24,23 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
uDataModuleServer, uDAClasses,
|
uDataModuleServer, uDAClasses,
|
||||||
schContactosClient_Intf, uBusinessUtils;
|
schContactosClient_Intf, uBusinessUtils, srvReferencias_Impl;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_PROVEEDORES = 'REF_PROVEEDORES';
|
||||||
|
|
||||||
{ TBizProveedorServer }
|
{ TBizProveedorServer }
|
||||||
|
|
||||||
|
function TBizProveedorServer.DarReferenciaContacto: String;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(REF_PROVEEDORES)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBizProveedorServer.Delete_Datos_Contacto(aChange: TDADeltaChange);
|
procedure TBizProveedorServer.Delete_Datos_Contacto(aChange: TDADeltaChange);
|
||||||
var
|
var
|
||||||
ASchema : TDASchema;
|
ASchema : TDASchema;
|
||||||
@ -48,6 +64,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizProveedorServer.IncrementarReferenciaContacto: Boolean;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(REF_PROVEEDORES, Self.REFERENCIA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBizProveedorServer.Insert_Datos_Contacto(aChange: TDADeltaChange);
|
procedure TBizProveedorServer.Insert_Datos_Contacto(aChange: TDADeltaChange);
|
||||||
var
|
var
|
||||||
ASchema : TDASchema;
|
ASchema : TDASchema;
|
||||||
|
|||||||
@ -249,6 +249,7 @@ object srvContactos: TsrvContactos
|
|||||||
Name = 'REFERENCIA'
|
Name = 'REFERENCIA'
|
||||||
DataType = datString
|
DataType = datString
|
||||||
Size = 255
|
Size = 255
|
||||||
|
ServerAutoRefresh = True
|
||||||
DictionaryEntry = 'Contactos_REFERENCIA'
|
DictionaryEntry = 'Contactos_REFERENCIA'
|
||||||
end>
|
end>
|
||||||
end
|
end
|
||||||
@ -652,6 +653,7 @@ object srvContactos: TsrvContactos
|
|||||||
Name = 'REFERENCIA'
|
Name = 'REFERENCIA'
|
||||||
DataType = datString
|
DataType = datString
|
||||||
Size = 255
|
Size = 255
|
||||||
|
ServerAutoRefresh = True
|
||||||
DictionaryEntry = 'Clientes_REFERENCIA'
|
DictionaryEntry = 'Clientes_REFERENCIA'
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
@ -989,6 +991,7 @@ object srvContactos: TsrvContactos
|
|||||||
Name = 'REFERENCIA'
|
Name = 'REFERENCIA'
|
||||||
DataType = datString
|
DataType = datString
|
||||||
Size = 255
|
Size = 255
|
||||||
|
ServerAutoRefresh = True
|
||||||
DictionaryEntry = 'Proveedores_REFERENCIA'
|
DictionaryEntry = 'Proveedores_REFERENCIA'
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
@ -1309,6 +1312,7 @@ object srvContactos: TsrvContactos
|
|||||||
Name = 'REFERENCIA'
|
Name = 'REFERENCIA'
|
||||||
DataType = datString
|
DataType = datString
|
||||||
Size = 255
|
Size = 255
|
||||||
|
ServerAutoRefresh = True
|
||||||
DictionaryEntry = 'Agentes_REFERENCIA'
|
DictionaryEntry = 'Agentes_REFERENCIA'
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
@ -4049,24 +4053,24 @@ object srvContactos: TsrvContactos
|
|||||||
Top = 82
|
Top = 82
|
||||||
DiagramData =
|
DiagramData =
|
||||||
'<Diagrams>'#13#10' <Diagram Name="Contactos" Left="200" Top="200" Wid' +
|
'<Diagrams>'#13#10' <Diagram Name="Contactos" Left="200" Top="200" Wid' +
|
||||||
'th="400" Height="300">'#13#10' <Entity Name="Contactos" Left="0,00"' +
|
'th="400" Height="300">'#13#10' <Entity Name="DatosBancarios" Left="' +
|
||||||
' Top="85,50" />'#13#10' <Entity Name="DireccionesContacto" Left="32' +
|
'325,90" Top="0,00" />'#13#10' <Entity Name="Contactos" Left="0,00" ' +
|
||||||
'0,90" Top="183,00" />'#13#10' <Entity Name="DatosBancarios" Left="3' +
|
'Top="85,50" />'#13#10' <Entity Name="DireccionesContacto" Left="320' +
|
||||||
'25,90" Top="0,00" />'#13#10' </Diagram>'#13#10' <Diagram Name="Clientes" L' +
|
',90" Top="183,00" />'#13#10' </Diagram>'#13#10' <Diagram Name="Clientes" L' +
|
||||||
'eft="200" Top="200" Width="400" Height="300">'#13#10' <Entity Name=' +
|
'eft="200" Top="200" Width="400" Height="300">'#13#10' <Entity Name=' +
|
||||||
'"Clientes" Left="0,00" Top="23,00" />'#13#10' <Entity Name="Direcci' +
|
'"DatosBancarios" Left="463,00" Top="175,00" />'#13#10' <Entity Name' +
|
||||||
'onesContacto" Left="253,00" Top="236,00" />'#13#10' <Entity Name="D' +
|
'="Clientes" Left="0,00" Top="23,00" />'#13#10' <Entity Name="Direcc' +
|
||||||
'atosBancarios" Left="463,00" Top="175,00" />'#13#10' <Entity Name="' +
|
'ionesContacto" Left="253,00" Top="236,00" />'#13#10' <Entity Name="' +
|
||||||
'ClientesDescuentos" Left="438,00" Top="0,00" />'#13#10' </Diagram>'#13#10' ' +
|
'ClientesDescuentos" Left="438,00" Top="0,00" />'#13#10' </Diagram>'#13#10' ' +
|
||||||
' <Diagram Name="Empleados" Left="200" Top="200" Width="400" Heig' +
|
' <Diagram Name="Empleados" Left="200" Top="200" Width="400" Heig' +
|
||||||
'ht="300">'#13#10' <Entity Name="DireccionesContacto" Left="295,00" ' +
|
'ht="300">'#13#10' <Entity Name="Empleados" Left="0,00" Top="42,00" ' +
|
||||||
'Top="0,00" />'#13#10' <Entity Name="DatosBancarios" Left="210,50" T' +
|
'/>'#13#10' <Entity Name="DatosBancarios" Left="210,50" Top="280,67"' +
|
||||||
'op="280,67" />'#13#10' <Entity Name="Empleados" Left="0,00" Top="42' +
|
' />'#13#10' <Entity Name="DireccionesContacto" Left="295,00" Top="0' +
|
||||||
',00" />'#13#10' </Diagram>'#13#10' <Diagram Name="Proveedores" Left="200" ' +
|
',00" />'#13#10' </Diagram>'#13#10' <Diagram Name="Proveedores" Left="200" ' +
|
||||||
'Top="200" Width="400" Height="300">'#13#10' <Entity Name="Proveedor' +
|
'Top="200" Width="400" Height="300">'#13#10' <Entity Name="DatosBanc' +
|
||||||
'es" Left="0,00" Top="115,17" />'#13#10' <Entity Name="DireccionesCo' +
|
'arios" Left="247,28" Top="242,04" />'#13#10' <Entity Name="Proveedo' +
|
||||||
'ntacto" Left="245,28" Top="0,00" />'#13#10' <Entity Name="DatosBanc' +
|
'res" Left="0,00" Top="115,17" />'#13#10' <Entity Name="DireccionesC' +
|
||||||
'arios" Left="247,28" Top="242,04" />'#13#10' </Diagram>'#13#10'</Diagrams>'#13 +
|
'ontacto" Left="245,28" Top="0,00" />'#13#10' </Diagram>'#13#10'</Diagrams>'#13 +
|
||||||
#10
|
#10
|
||||||
end
|
end
|
||||||
object bpContactos: TDABusinessProcessor
|
object bpContactos: TDABusinessProcessor
|
||||||
|
|||||||
@ -9,21 +9,13 @@ const
|
|||||||
{ Data table rules ids
|
{ Data table rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferencia = '{CC46C1A7-C6CE-4ABE-B1A8-4C2BABFB5C93}';
|
RID_FacturasCliente = '{95C2DDE4-5EF1-40A4-87CD-E29B422E222D}';
|
||||||
RID_FacturasCliente = '{51E6C07A-D580-46D7-9032-1838AF4D4B07}';
|
RID_FacturasCliente_Detalles = '{010F12C4-9C39-4203-B705-9D757B685A11}';
|
||||||
RID_FacturasCliente_Detalles = '{8A70D0F2-F09E-4166-A792-00012AA7C35A}';
|
|
||||||
|
|
||||||
{ Data table names }
|
{ Data table names }
|
||||||
nme_DarReferencia = 'DarReferencia';
|
|
||||||
nme_FacturasCliente = 'FacturasCliente';
|
nme_FacturasCliente = 'FacturasCliente';
|
||||||
nme_FacturasCliente_Detalles = 'FacturasCliente_Detalles';
|
nme_FacturasCliente_Detalles = 'FacturasCliente_Detalles';
|
||||||
|
|
||||||
{ DarReferencia fields }
|
|
||||||
fld_DarReferenciaVALOR = 'VALOR';
|
|
||||||
|
|
||||||
{ DarReferencia field indexes }
|
|
||||||
idx_DarReferenciaVALOR = 0;
|
|
||||||
|
|
||||||
{ FacturasCliente fields }
|
{ FacturasCliente fields }
|
||||||
fld_FacturasClienteID = 'ID';
|
fld_FacturasClienteID = 'ID';
|
||||||
fld_FacturasClienteID_EMPRESA = 'ID_EMPRESA';
|
fld_FacturasClienteID_EMPRESA = 'ID_EMPRESA';
|
||||||
@ -127,44 +119,9 @@ const
|
|||||||
idx_FacturasCliente_DetallesREFERENCIA_PROVEEDOR = 13;
|
idx_FacturasCliente_DetallesREFERENCIA_PROVEEDOR = 13;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferencia }
|
|
||||||
IDarReferencia = interface(IDAStronglyTypedDataTable)
|
|
||||||
['{3338E715-B18C-4550-BE4C-C92B071770B4}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String;
|
|
||||||
procedure SetVALORValue(const aValue: String);
|
|
||||||
function GetVALORIsNull: Boolean;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean);
|
|
||||||
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
TDarReferenciaDataTableRules = class(TIntfObjectDADataTableRules, IDarReferencia)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aDataTable: TDADataTable); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IFacturasCliente }
|
{ IFacturasCliente }
|
||||||
IFacturasCliente = interface(IDAStronglyTypedDataTable)
|
IFacturasCliente = interface(IDAStronglyTypedDataTable)
|
||||||
['{0ACBE344-A040-4AD4-8037-DA9382B4D9CF}']
|
['{F5184C4A-3061-4D25-A4A7-9B93249B7D92}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -583,7 +540,7 @@ type
|
|||||||
|
|
||||||
{ IFacturasCliente_Detalles }
|
{ IFacturasCliente_Detalles }
|
||||||
IFacturasCliente_Detalles = interface(IDAStronglyTypedDataTable)
|
IFacturasCliente_Detalles = interface(IDAStronglyTypedDataTable)
|
||||||
['{E62E97AD-C08F-4BB6-A6EF-21BF966630A0}']
|
['{777CB660-EDDA-4CEE-9992-604ED4D8A2D7}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -776,39 +733,6 @@ implementation
|
|||||||
|
|
||||||
uses Variants, uROBinaryHelpers;
|
uses Variants, uROBinaryHelpers;
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
constructor TDarReferenciaDataTableRules.Create(aDataTable: TDADataTable);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaDataTableRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].AsString;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsString := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORIsNull: boolean;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].IsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsVariant := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TFacturasClienteDataTableRules }
|
{ TFacturasClienteDataTableRules }
|
||||||
constructor TFacturasClienteDataTableRules.Create(aDataTable: TDADataTable);
|
constructor TFacturasClienteDataTableRules.Create(aDataTable: TDADataTable);
|
||||||
var
|
var
|
||||||
@ -1828,7 +1752,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterDataTableRules(RID_DarReferencia, TDarReferenciaDataTableRules);
|
|
||||||
RegisterDataTableRules(RID_FacturasCliente, TFacturasClienteDataTableRules);
|
RegisterDataTableRules(RID_FacturasCliente, TFacturasClienteDataTableRules);
|
||||||
RegisterDataTableRules(RID_FacturasCliente_Detalles, TFacturasCliente_DetallesDataTableRules);
|
RegisterDataTableRules(RID_FacturasCliente_Detalles, TFacturasCliente_DetallesDataTableRules);
|
||||||
|
|
||||||
|
|||||||
@ -9,48 +9,13 @@ const
|
|||||||
{ Delta rules ids
|
{ Delta rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferenciaDelta = '{E8B8EB94-54CB-49B3-879C-1CF0319BCBBD}';
|
RID_FacturasClienteDelta = '{A8659C85-51C8-44A3-9790-F3A3C50AA03D}';
|
||||||
RID_FacturasClienteDelta = '{EC7543D0-B0B5-48F9-9401-DEEE0D0BEFF2}';
|
RID_FacturasCliente_DetallesDelta = '{BEF54047-703B-4F62-9C73-0F2DB7BF03B4}';
|
||||||
RID_FacturasCliente_DetallesDelta = '{A1C5C789-FF93-491C-82C6-A49EF37F27A3}';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferenciaDelta }
|
|
||||||
IDarReferenciaDelta = interface(IDarReferencia)
|
|
||||||
['{E8B8EB94-54CB-49B3-879C-1CF0319BCBBD}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetOldVALORValue : String;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
TDarReferenciaBusinessProcessorRules = class(TDABusinessProcessorRules, IDarReferencia, IDarReferenciaDelta)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
function GetOldVALORValue: String; virtual;
|
|
||||||
function GetOldVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR : String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull : Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
property OldVALORIsNull : Boolean read GetOldVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aBusinessProcessor: TDABusinessProcessor); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IFacturasClienteDelta }
|
{ IFacturasClienteDelta }
|
||||||
IFacturasClienteDelta = interface(IFacturasCliente)
|
IFacturasClienteDelta = interface(IFacturasCliente)
|
||||||
['{EC7543D0-B0B5-48F9-9401-DEEE0D0BEFF2}']
|
['{A8659C85-51C8-44A3-9790-F3A3C50AA03D}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_EMPRESAValue : Integer;
|
function GetOldID_EMPRESAValue : Integer;
|
||||||
@ -469,7 +434,7 @@ type
|
|||||||
|
|
||||||
{ IFacturasCliente_DetallesDelta }
|
{ IFacturasCliente_DetallesDelta }
|
||||||
IFacturasCliente_DetallesDelta = interface(IFacturasCliente_Detalles)
|
IFacturasCliente_DetallesDelta = interface(IFacturasCliente_Detalles)
|
||||||
['{A1C5C789-FF93-491C-82C6-A49EF37F27A3}']
|
['{BEF54047-703B-4F62-9C73-0F2DB7BF03B4}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_FACTURAValue : Integer;
|
function GetOldID_FACTURAValue : Integer;
|
||||||
@ -662,49 +627,6 @@ implementation
|
|||||||
uses
|
uses
|
||||||
Variants, uROBinaryHelpers, uDAInterfaces;
|
Variants, uROBinaryHelpers, uDAInterfaces;
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
constructor TDarReferenciaBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaBusinessProcessorRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TFacturasClienteBusinessProcessorRules }
|
{ TFacturasClienteBusinessProcessorRules }
|
||||||
constructor TFacturasClienteBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
constructor TFacturasClienteBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
||||||
var
|
var
|
||||||
@ -2195,7 +2117,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(RID_DarReferenciaDelta, TDarReferenciaBusinessProcessorRules);
|
|
||||||
RegisterBusinessProcessorRules(RID_FacturasClienteDelta, TFacturasClienteBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_FacturasClienteDelta, TFacturasClienteBusinessProcessorRules);
|
||||||
RegisterBusinessProcessorRules(RID_FacturasCliente_DetallesDelta, TFacturasCliente_DetallesBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_FacturasCliente_DetallesDelta, TFacturasCliente_DetallesBusinessProcessorRules);
|
||||||
|
|
||||||
|
|||||||
@ -8,80 +8,112 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
BIZ_SERVER_FACTURAS_CLIENTE = 'Server.FacturasCliente';
|
BIZ_SERVER_FACTURAS_CLIENTE = 'Server.FacturasCliente';
|
||||||
REF_FACTURAS_CLIENTE = 'REF_FACTURAS_CLIENTE';
|
|
||||||
REF_ABONOS_CLIENTE = 'REF_ABONOS_CLIENTE';
|
|
||||||
CTE_TIPO_ABONO = 'A';
|
|
||||||
CTE_TIPO_FACTURA = 'F';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TBizFacturasClienteServer = class(TFacturasClienteBusinessProcessorRules)
|
TBizFacturasClienteServer = class(TFacturasClienteBusinessProcessorRules)
|
||||||
|
private
|
||||||
|
FReferenciaAutomatica : Boolean;
|
||||||
|
function DarReferencia : String;
|
||||||
|
function IncrementarReferencia : Boolean;
|
||||||
protected
|
protected
|
||||||
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
|
||||||
|
const aDelta: IDADelta); override;
|
||||||
|
procedure AfterProcessChange(Sender: TDABusinessProcessor;
|
||||||
|
aChange: TDADeltaChange; Processed: Boolean;
|
||||||
|
var CanRemoveFromDelta: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
Variants, uDAClasses, srvReferencias_Impl, uBusinessUtils, uROClasses,
|
||||||
schFacturasClienteClient_Intf;
|
uDataModuleServer, schFacturasClienteClient_Intf;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_FACTURAS_CLIENTE = 'REF_FACTURAS_CLIENTE';
|
||||||
|
REF_ABONOS_CLIENTE = 'REF_ABONOS_CLIENTE';
|
||||||
|
CTE_TIPO_ABONO = 'A';
|
||||||
|
CTE_TIPO_FACTURA = 'F';
|
||||||
|
|
||||||
|
|
||||||
{ TBizFacturasClienteServer }
|
{ TBizFacturasClienteServer }
|
||||||
|
|
||||||
procedure TBizFacturasClienteServer.BeforeProcessDelta(
|
procedure TBizFacturasClienteServer.AfterProcessChange(
|
||||||
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
|
||||||
var
|
var CanRemoveFromDelta: Boolean);
|
||||||
ASchema : TDASchema;
|
|
||||||
ACurrentConn : IDAConnection;
|
|
||||||
dsData: IDADataset;
|
|
||||||
Empresa : Variant;
|
|
||||||
Tipo : Variant;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
{ Por defecto, no es necesario mantener los deltas una vez
|
||||||
|
procesados los cambios. }
|
||||||
|
CanRemoveFromDelta := True;
|
||||||
|
|
||||||
|
case aChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferencia;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
{ En este caso no debemos quitar los deltas porque
|
||||||
|
el cliente tiene que enterarse de la referencia que
|
||||||
|
ha rellenado el servidor. }
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBizFacturasClienteServer.BeforeProcessDelta(
|
||||||
|
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
||||||
|
begin
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
|
||||||
case Sender.CurrentChange.ChangeType of
|
case Sender.CurrentChange.ChangeType of
|
||||||
ctInsert, ctUpdate: begin
|
ctInsert, ctUpdate: begin
|
||||||
//Si la referencia no ha sido asignada le asignamos una nosotros
|
//Si la referencia no ha sido asignada le asignamos una nosotros
|
||||||
if (VarIsNull(Sender.CurrentChange.NewValueByName[fld_FacturasClienteREFERENCIA]))
|
if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then
|
||||||
or (VarToStr(Sender.CurrentChange.NewValueByName[fld_FacturasClienteREFERENCIA]) = '') then
|
|
||||||
begin
|
begin
|
||||||
ASchema := BusinessProcessor.Schema;
|
FReferenciaAutomatica := True;
|
||||||
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
|
REFERENCIA := DarReferencia;
|
||||||
|
|
||||||
try
|
|
||||||
//Siempre va a estar rellena
|
|
||||||
Empresa := Sender.CurrentChange.NewValueByName[fld_FacturasClienteID_EMPRESA];
|
|
||||||
Tipo := Sender.CurrentChange.NewValueByName[fld_FacturasClienteTIPO];
|
|
||||||
|
|
||||||
if Tipo = CTE_TIPO_FACTURA then
|
|
||||||
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_FACTURAS_CLIENTE, Empresa])
|
|
||||||
else
|
|
||||||
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_ABONOS_CLIENTE, Empresa]);
|
|
||||||
|
|
||||||
except
|
|
||||||
RaiseError('No existe la tabla REFERENCIAS');
|
|
||||||
end;
|
|
||||||
|
|
||||||
dsData.Active := True;
|
|
||||||
|
|
||||||
if dsData.IsEmpty then
|
|
||||||
RaiseError('NO HAY REFERENCIA ' + REF_FACTURAS_CLIENTE + ' / ' + REF_ABONOS_CLIENTE + ' DECLARADA EN TABLA REFERENCIAS');
|
|
||||||
|
|
||||||
REFERENCIA := dsData.FieldByName('VALOR').AsString;
|
|
||||||
|
|
||||||
try
|
|
||||||
if Tipo = CTE_TIPO_FACTURA then
|
|
||||||
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'EMPRESA'], [REF_FACTURAS_CLIENTE, DarReferenciaSiguiente(REFERENCIA), Empresa])
|
|
||||||
else
|
|
||||||
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'EMPRESA'], [REF_ABONOS_CLIENTE, DarReferenciaSiguiente(REFERENCIA), Empresa]);
|
|
||||||
|
|
||||||
except
|
|
||||||
RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla');
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizFacturasClienteServer.DarReferencia: String;
|
||||||
|
var
|
||||||
|
ATipo : String;
|
||||||
|
begin
|
||||||
|
if TIPO = CTE_TIPO_FACTURA then
|
||||||
|
ATipo := REF_FACTURAS_CLIENTE
|
||||||
|
else
|
||||||
|
ATipo := REF_ABONOS_CLIENTE;
|
||||||
|
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(ATipo, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBizFacturasClienteServer.IncrementarReferencia: Boolean;
|
||||||
|
var
|
||||||
|
ATipo : String;
|
||||||
|
begin
|
||||||
|
if TIPO = CTE_TIPO_FACTURA then
|
||||||
|
ATipo := REF_FACTURAS_CLIENTE
|
||||||
|
else
|
||||||
|
ATipo := REF_ABONOS_CLIENTE;
|
||||||
|
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(ATipo,
|
||||||
|
Self.REFERENCIA, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(BIZ_SERVER_FACTURAS_CLIENTE, TBizFacturasClienteServer);
|
RegisterBusinessProcessorRules(BIZ_SERVER_FACTURAS_CLIENTE, TBizFacturasClienteServer);
|
||||||
|
|
||||||
|
|||||||
@ -15,42 +15,6 @@ object srvFacturasCliente: TsrvFacturasCliente
|
|||||||
DataDictionary = DataDictionary
|
DataDictionary = DataDictionary
|
||||||
Diagrams = Diagrams
|
Diagrams = Diagrams
|
||||||
Datasets = <
|
Datasets = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
DataType = datString
|
|
||||||
Size = 50
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'SELECT VALOR'#10'FROM REFERENCIAS'#10'WHERE CODIGO = :CODIGO'#10'AND ID_EMPR' +
|
|
||||||
'ESA = :EMPRESA'
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <
|
|
||||||
item
|
|
||||||
DatasetField = 'VALOR'
|
|
||||||
TableField = 'VALOR'
|
|
||||||
end>
|
|
||||||
end>
|
|
||||||
Name = 'DarReferencia'
|
|
||||||
Fields = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
DataType = datString
|
|
||||||
Size = 255
|
|
||||||
end>
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <>
|
Params = <>
|
||||||
Statements = <
|
Statements = <
|
||||||
@ -534,31 +498,6 @@ object srvFacturasCliente: TsrvFacturasCliente
|
|||||||
JoinDataTables = <>
|
JoinDataTables = <>
|
||||||
UnionDataTables = <>
|
UnionDataTables = <>
|
||||||
Commands = <
|
Commands = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
SQL =
|
|
||||||
'UPDATE REFERENCIAS SET'#10' VALOR = :VALOR'#10'WHERE CODIGO = :COD' +
|
|
||||||
'IGO AND'#10' ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <>
|
|
||||||
end>
|
|
||||||
Name = 'ModificarReferencia'
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <
|
Params = <
|
||||||
item
|
item
|
||||||
|
|||||||
@ -9,21 +9,13 @@ const
|
|||||||
{ Data table rules ids
|
{ Data table rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferencia = '{5C2671F2-30A9-40DF-85EB-DAC3E5798C81}';
|
RID_FacturasProveedor = '{88E29988-90B3-4F11-BDD5-725B135C5155}';
|
||||||
RID_FacturasProveedor = '{EB88CFA6-A4F3-44A5-99AC-CEEF636BBC0F}';
|
RID_FacturasProveedor_Detalles = '{B8192582-A958-4BCC-A261-5608584C2B67}';
|
||||||
RID_FacturasProveedor_Detalles = '{794BFE28-FCFA-451E-809D-4B3204729DB8}';
|
|
||||||
|
|
||||||
{ Data table names }
|
{ Data table names }
|
||||||
nme_DarReferencia = 'DarReferencia';
|
|
||||||
nme_FacturasProveedor = 'FacturasProveedor';
|
nme_FacturasProveedor = 'FacturasProveedor';
|
||||||
nme_FacturasProveedor_Detalles = 'FacturasProveedor_Detalles';
|
nme_FacturasProveedor_Detalles = 'FacturasProveedor_Detalles';
|
||||||
|
|
||||||
{ DarReferencia fields }
|
|
||||||
fld_DarReferenciaVALOR = 'VALOR';
|
|
||||||
|
|
||||||
{ DarReferencia field indexes }
|
|
||||||
idx_DarReferenciaVALOR = 0;
|
|
||||||
|
|
||||||
{ FacturasProveedor fields }
|
{ FacturasProveedor fields }
|
||||||
fld_FacturasProveedorID = 'ID';
|
fld_FacturasProveedorID = 'ID';
|
||||||
fld_FacturasProveedorID_EMPRESA = 'ID_EMPRESA';
|
fld_FacturasProveedorID_EMPRESA = 'ID_EMPRESA';
|
||||||
@ -123,44 +115,9 @@ const
|
|||||||
idx_FacturasProveedor_DetallesREFERENCIA_PROVEEDOR = 13;
|
idx_FacturasProveedor_DetallesREFERENCIA_PROVEEDOR = 13;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferencia }
|
|
||||||
IDarReferencia = interface(IDAStronglyTypedDataTable)
|
|
||||||
['{2CD8615C-AC9E-463D-A28B-9DF7EA71C261}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String;
|
|
||||||
procedure SetVALORValue(const aValue: String);
|
|
||||||
function GetVALORIsNull: Boolean;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean);
|
|
||||||
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
TDarReferenciaDataTableRules = class(TIntfObjectDADataTableRules, IDarReferencia)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aDataTable: TDADataTable); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IFacturasProveedor }
|
{ IFacturasProveedor }
|
||||||
IFacturasProveedor = interface(IDAStronglyTypedDataTable)
|
IFacturasProveedor = interface(IDAStronglyTypedDataTable)
|
||||||
['{19ADA8D8-BA53-426F-9AFA-700B29166843}']
|
['{E152D3B2-9282-492A-8E11-DDBE597C9FB1}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -555,7 +512,7 @@ type
|
|||||||
|
|
||||||
{ IFacturasProveedor_Detalles }
|
{ IFacturasProveedor_Detalles }
|
||||||
IFacturasProveedor_Detalles = interface(IDAStronglyTypedDataTable)
|
IFacturasProveedor_Detalles = interface(IDAStronglyTypedDataTable)
|
||||||
['{8C420A12-5489-4872-A3A6-9DE83225D778}']
|
['{97403572-2108-4BF9-BD7B-4359FD2F8C8D}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -748,39 +705,6 @@ implementation
|
|||||||
|
|
||||||
uses Variants, uROBinaryHelpers;
|
uses Variants, uROBinaryHelpers;
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
constructor TDarReferenciaDataTableRules.Create(aDataTable: TDADataTable);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaDataTableRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].AsString;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsString := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORIsNull: boolean;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].IsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsVariant := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TFacturasProveedorDataTableRules }
|
{ TFacturasProveedorDataTableRules }
|
||||||
constructor TFacturasProveedorDataTableRules.Create(aDataTable: TDADataTable);
|
constructor TFacturasProveedorDataTableRules.Create(aDataTable: TDADataTable);
|
||||||
var
|
var
|
||||||
@ -1758,7 +1682,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterDataTableRules(RID_DarReferencia, TDarReferenciaDataTableRules);
|
|
||||||
RegisterDataTableRules(RID_FacturasProveedor, TFacturasProveedorDataTableRules);
|
RegisterDataTableRules(RID_FacturasProveedor, TFacturasProveedorDataTableRules);
|
||||||
RegisterDataTableRules(RID_FacturasProveedor_Detalles, TFacturasProveedor_DetallesDataTableRules);
|
RegisterDataTableRules(RID_FacturasProveedor_Detalles, TFacturasProveedor_DetallesDataTableRules);
|
||||||
|
|
||||||
|
|||||||
@ -9,48 +9,13 @@ const
|
|||||||
{ Delta rules ids
|
{ Delta rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferenciaDelta = '{29799EE8-6169-4A26-9C4C-02C33D658D97}';
|
RID_FacturasProveedorDelta = '{E53CF4C8-D5FB-42BC-AA69-3E77733F61F0}';
|
||||||
RID_FacturasProveedorDelta = '{90E2FE05-93D9-4478-B54E-73618BD635BF}';
|
RID_FacturasProveedor_DetallesDelta = '{6CC27603-B23C-40C4-9D22-8CFC5E1B738F}';
|
||||||
RID_FacturasProveedor_DetallesDelta = '{9215693E-0AA6-46A8-AD7B-3EAE75F51EFE}';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferenciaDelta }
|
|
||||||
IDarReferenciaDelta = interface(IDarReferencia)
|
|
||||||
['{29799EE8-6169-4A26-9C4C-02C33D658D97}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetOldVALORValue : String;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
TDarReferenciaBusinessProcessorRules = class(TDABusinessProcessorRules, IDarReferencia, IDarReferenciaDelta)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
function GetOldVALORValue: String; virtual;
|
|
||||||
function GetOldVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR : String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull : Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
property OldVALORIsNull : Boolean read GetOldVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aBusinessProcessor: TDABusinessProcessor); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IFacturasProveedorDelta }
|
{ IFacturasProveedorDelta }
|
||||||
IFacturasProveedorDelta = interface(IFacturasProveedor)
|
IFacturasProveedorDelta = interface(IFacturasProveedor)
|
||||||
['{90E2FE05-93D9-4478-B54E-73618BD635BF}']
|
['{E53CF4C8-D5FB-42BC-AA69-3E77733F61F0}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_EMPRESAValue : Integer;
|
function GetOldID_EMPRESAValue : Integer;
|
||||||
@ -445,7 +410,7 @@ type
|
|||||||
|
|
||||||
{ IFacturasProveedor_DetallesDelta }
|
{ IFacturasProveedor_DetallesDelta }
|
||||||
IFacturasProveedor_DetallesDelta = interface(IFacturasProveedor_Detalles)
|
IFacturasProveedor_DetallesDelta = interface(IFacturasProveedor_Detalles)
|
||||||
['{9215693E-0AA6-46A8-AD7B-3EAE75F51EFE}']
|
['{6CC27603-B23C-40C4-9D22-8CFC5E1B738F}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_FACTURAValue : Integer;
|
function GetOldID_FACTURAValue : Integer;
|
||||||
@ -638,49 +603,6 @@ implementation
|
|||||||
uses
|
uses
|
||||||
Variants, uROBinaryHelpers, uDAInterfaces;
|
Variants, uROBinaryHelpers, uDAInterfaces;
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
constructor TDarReferenciaBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaBusinessProcessorRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TFacturasProveedorBusinessProcessorRules }
|
{ TFacturasProveedorBusinessProcessorRules }
|
||||||
constructor TFacturasProveedorBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
constructor TFacturasProveedorBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
||||||
var
|
var
|
||||||
@ -2109,7 +2031,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(RID_DarReferenciaDelta, TDarReferenciaBusinessProcessorRules);
|
|
||||||
RegisterBusinessProcessorRules(RID_FacturasProveedorDelta, TFacturasProveedorBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_FacturasProveedorDelta, TFacturasProveedorBusinessProcessorRules);
|
||||||
RegisterBusinessProcessorRules(RID_FacturasProveedor_DetallesDelta, TFacturasProveedor_DetallesBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_FacturasProveedor_DetallesDelta, TFacturasProveedor_DetallesBusinessProcessorRules);
|
||||||
|
|
||||||
|
|||||||
@ -8,80 +8,112 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
BIZ_SERVER_FACTURAS_PROVEEDOR = 'Server.FacturasProveedor';
|
BIZ_SERVER_FACTURAS_PROVEEDOR = 'Server.FacturasProveedor';
|
||||||
REF_FACTURAS_PROVEEDOR = 'REF_FACTURAS_PROVEEDOR';
|
|
||||||
REF_ABONOS_PROVEEDOR = 'REF_ABONOS_PROVEEDOR';
|
|
||||||
CTE_TIPO_ABONO = 'A';
|
|
||||||
CTE_TIPO_FACTURA = 'F';
|
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TBizFacturasProveedorServer = class(TFacturasProveedorBusinessProcessorRules)
|
TBizFacturasProveedorServer = class(TFacturasProveedorBusinessProcessorRules)
|
||||||
|
private
|
||||||
|
FReferenciaAutomatica : Boolean;
|
||||||
|
function DarReferencia : String;
|
||||||
|
function IncrementarReferencia : Boolean;
|
||||||
protected
|
protected
|
||||||
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
|
||||||
|
const aDelta: IDADelta); override;
|
||||||
|
procedure AfterProcessChange(Sender: TDABusinessProcessor;
|
||||||
|
aChange: TDADeltaChange; Processed: Boolean;
|
||||||
|
var CanRemoveFromDelta: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
||||||
schFacturasProveedorClient_Intf;
|
schFacturasProveedorClient_Intf, srvReferencias_Impl;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_FACTURAS_PROVEEDOR = 'REF_FACTURAS_PROVEEDOR';
|
||||||
|
REF_ABONOS_PROVEEDOR = 'REF_ABONOS_PROVEEDOR';
|
||||||
|
CTE_TIPO_ABONO = 'A';
|
||||||
|
CTE_TIPO_FACTURA = 'F';
|
||||||
|
|
||||||
|
|
||||||
{ TBizFacturasProveedorServer }
|
{ TBizFacturasProveedorServer }
|
||||||
|
|
||||||
procedure TBizFacturasProveedorServer.BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
procedure TBizFacturasProveedorServer.AfterProcessChange(
|
||||||
var
|
Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
|
||||||
ASchema : TDASchema;
|
var CanRemoveFromDelta: Boolean);
|
||||||
ACurrentConn : IDAConnection;
|
|
||||||
dsData: IDADataset;
|
|
||||||
Empresa : Variant;
|
|
||||||
Tipo : Variant;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
{ Por defecto, no es necesario mantener los deltas una vez
|
||||||
|
procesados los cambios. }
|
||||||
|
CanRemoveFromDelta := True;
|
||||||
|
|
||||||
|
case aChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferencia;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
{ En este caso no debemos quitar los deltas porque
|
||||||
|
el cliente tiene que enterarse de la referencia que
|
||||||
|
ha rellenado el servidor. }
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBizFacturasProveedorServer.BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
||||||
|
begin
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
|
||||||
case Sender.CurrentChange.ChangeType of
|
case Sender.CurrentChange.ChangeType of
|
||||||
ctInsert, ctUpdate: begin
|
ctInsert, ctUpdate: begin
|
||||||
//Si la referencia no ha sido asignada le asignamos una nosotros
|
//Si la referencia no ha sido asignada le asignamos una nosotros
|
||||||
if (VarIsNull(Sender.CurrentChange.NewValueByName[fld_FacturasProveedorREFERENCIA]))
|
if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then
|
||||||
or (VarToStr(Sender.CurrentChange.NewValueByName[fld_FacturasProveedorREFERENCIA]) = '') then
|
|
||||||
begin
|
begin
|
||||||
ASchema := BusinessProcessor.Schema;
|
FReferenciaAutomatica := True;
|
||||||
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
|
REFERENCIA := DarReferencia;
|
||||||
|
|
||||||
try
|
|
||||||
//Siempre va a estar rellena
|
|
||||||
Empresa := Sender.CurrentChange.NewValueByName[fld_FacturasProveedorID_EMPRESA];
|
|
||||||
Tipo := Sender.CurrentChange.NewValueByName[fld_FacturasProveedorTIPO];
|
|
||||||
|
|
||||||
if Tipo = CTE_TIPO_FACTURA then
|
|
||||||
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_FACTURAS_PROVEEDOR, Empresa])
|
|
||||||
else
|
|
||||||
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_ABONOS_PROVEEDOR, Empresa]);
|
|
||||||
|
|
||||||
except
|
|
||||||
RaiseError('No existe la tabla REFERENCIAS');
|
|
||||||
end;
|
|
||||||
|
|
||||||
dsData.Active := True;
|
|
||||||
|
|
||||||
if dsData.IsEmpty then
|
|
||||||
RaiseError('NO HAY REFERENCIA ' + REF_FACTURAS_PROVEEDOR + ' / ' + REF_ABONOS_PROVEEDOR + ' DECLARADA EN TABLA REFERENCIAS');
|
|
||||||
|
|
||||||
REFERENCIA := dsData.FieldByName('VALOR').AsString;
|
|
||||||
|
|
||||||
try
|
|
||||||
if Tipo = CTE_TIPO_FACTURA then
|
|
||||||
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'EMPRESA'], [REF_FACTURAS_PROVEEDOR, DarReferenciaSiguiente(REFERENCIA), Empresa])
|
|
||||||
else
|
|
||||||
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'EMPRESA'], [REF_ABONOS_PROVEEDOR, DarReferenciaSiguiente(REFERENCIA), Empresa]);
|
|
||||||
|
|
||||||
except
|
|
||||||
RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla');
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizFacturasProveedorServer.DarReferencia: String;
|
||||||
|
var
|
||||||
|
ATipo : String;
|
||||||
|
begin
|
||||||
|
if TIPO = CTE_TIPO_FACTURA then
|
||||||
|
ATipo := REF_FACTURAS_PROVEEDOR
|
||||||
|
else
|
||||||
|
ATipo := REF_ABONOS_PROVEEDOR;
|
||||||
|
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(ATipo, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBizFacturasProveedorServer.IncrementarReferencia: Boolean;
|
||||||
|
var
|
||||||
|
ATipo : String;
|
||||||
|
begin
|
||||||
|
if TIPO = CTE_TIPO_FACTURA then
|
||||||
|
ATipo := REF_FACTURAS_PROVEEDOR
|
||||||
|
else
|
||||||
|
ATipo := REF_ABONOS_PROVEEDOR;
|
||||||
|
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(ATipo,
|
||||||
|
Self.REFERENCIA, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(BIZ_SERVER_FACTURAS_PROVEEDOR, TBizFacturasProveedorServer);
|
RegisterBusinessProcessorRules(BIZ_SERVER_FACTURAS_PROVEEDOR, TBizFacturasProveedorServer);
|
||||||
|
|
||||||
|
|||||||
@ -15,42 +15,6 @@ object srvFacturasProveedor: TsrvFacturasProveedor
|
|||||||
DataDictionary = DataDictionary
|
DataDictionary = DataDictionary
|
||||||
Diagrams = Diagrams
|
Diagrams = Diagrams
|
||||||
Datasets = <
|
Datasets = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
DataType = datString
|
|
||||||
Size = 50
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'SELECT VALOR'#10'FROM REFERENCIAS'#10'WHERE CODIGO = :CODIGO'#10'AND ID_EMPR' +
|
|
||||||
'ESA = :EMPRESA'
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <
|
|
||||||
item
|
|
||||||
DatasetField = 'VALOR'
|
|
||||||
TableField = 'VALOR'
|
|
||||||
end>
|
|
||||||
end>
|
|
||||||
Name = 'DarReferencia'
|
|
||||||
Fields = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
DataType = datString
|
|
||||||
Size = 255
|
|
||||||
end>
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <>
|
Params = <>
|
||||||
Statements = <
|
Statements = <
|
||||||
@ -519,31 +483,6 @@ object srvFacturasProveedor: TsrvFacturasProveedor
|
|||||||
JoinDataTables = <>
|
JoinDataTables = <>
|
||||||
UnionDataTables = <>
|
UnionDataTables = <>
|
||||||
Commands = <
|
Commands = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
SQL =
|
|
||||||
'UPDATE REFERENCIAS SET'#10' VALOR = :VALOR'#10'WHERE CODIGO = :COD' +
|
|
||||||
'IGO AND'#10' ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <>
|
|
||||||
end>
|
|
||||||
Name = 'ModificarReferencia'
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <
|
Params = <
|
||||||
item
|
item
|
||||||
|
|||||||
@ -9,23 +9,15 @@ const
|
|||||||
{ Data table rules ids
|
{ Data table rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferencia = '{CA7994DB-6CC3-4494-8CDA-4D8411DB5D2D}';
|
RID_PedidosProveedor = '{58DE490F-21E7-46A0-8553-F18015CAF07E}';
|
||||||
RID_PedidosProveedor = '{684C5776-911B-490A-9C71-D4EDCCAD631E}';
|
RID_PedidosProveedor_Detalles = '{1F8FEB94-42A3-4DC3-BB9B-33D96BAB6B5E}';
|
||||||
RID_PedidosProveedor_Detalles = '{FCF3DE95-4073-4679-92C0-87B7E7C46108}';
|
RID_PedidosProveedor_Articulos_Pendientes = '{0864581D-D5D3-441D-9296-22C2CFB6DE3B}';
|
||||||
RID_PedidosProveedor_Articulos_Pendientes = '{EA978B2E-441A-49F8-AF4D-76517D74CF10}';
|
|
||||||
|
|
||||||
{ Data table names }
|
{ Data table names }
|
||||||
nme_DarReferencia = 'DarReferencia';
|
|
||||||
nme_PedidosProveedor = 'PedidosProveedor';
|
nme_PedidosProveedor = 'PedidosProveedor';
|
||||||
nme_PedidosProveedor_Detalles = 'PedidosProveedor_Detalles';
|
nme_PedidosProveedor_Detalles = 'PedidosProveedor_Detalles';
|
||||||
nme_PedidosProveedor_Articulos_Pendientes = 'PedidosProveedor_Articulos_Pendientes';
|
nme_PedidosProveedor_Articulos_Pendientes = 'PedidosProveedor_Articulos_Pendientes';
|
||||||
|
|
||||||
{ DarReferencia fields }
|
|
||||||
fld_DarReferenciaVALOR = 'VALOR';
|
|
||||||
|
|
||||||
{ DarReferencia field indexes }
|
|
||||||
idx_DarReferenciaVALOR = 0;
|
|
||||||
|
|
||||||
{ PedidosProveedor fields }
|
{ PedidosProveedor fields }
|
||||||
fld_PedidosProveedorID = 'ID';
|
fld_PedidosProveedorID = 'ID';
|
||||||
fld_PedidosProveedorID_EMPRESA = 'ID_EMPRESA';
|
fld_PedidosProveedorID_EMPRESA = 'ID_EMPRESA';
|
||||||
@ -149,44 +141,9 @@ const
|
|||||||
idx_PedidosProveedor_Articulos_PendientesREFERENCIA_PROVEEDOR = 5;
|
idx_PedidosProveedor_Articulos_PendientesREFERENCIA_PROVEEDOR = 5;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferencia }
|
|
||||||
IDarReferencia = interface(IDAStronglyTypedDataTable)
|
|
||||||
['{04456888-5D38-48BB-8CED-95617D1F2BB9}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String;
|
|
||||||
procedure SetVALORValue(const aValue: String);
|
|
||||||
function GetVALORIsNull: Boolean;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean);
|
|
||||||
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
TDarReferenciaDataTableRules = class(TIntfObjectDADataTableRules, IDarReferencia)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aDataTable: TDADataTable); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IPedidosProveedor }
|
{ IPedidosProveedor }
|
||||||
IPedidosProveedor = interface(IDAStronglyTypedDataTable)
|
IPedidosProveedor = interface(IDAStronglyTypedDataTable)
|
||||||
['{4E3D9B42-CF76-460B-8136-2D0C2B3417D4}']
|
['{045CE31C-5F13-4365-94D8-09C247E0B609}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -629,7 +586,7 @@ type
|
|||||||
|
|
||||||
{ IPedidosProveedor_Detalles }
|
{ IPedidosProveedor_Detalles }
|
||||||
IPedidosProveedor_Detalles = interface(IDAStronglyTypedDataTable)
|
IPedidosProveedor_Detalles = interface(IDAStronglyTypedDataTable)
|
||||||
['{127BE3FD-DEF4-4C58-ABC5-5A54DCE0608D}']
|
['{10B7129B-0AD0-476C-AA42-807F150AA7B3}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -820,7 +777,7 @@ type
|
|||||||
|
|
||||||
{ IPedidosProveedor_Articulos_Pendientes }
|
{ IPedidosProveedor_Articulos_Pendientes }
|
||||||
IPedidosProveedor_Articulos_Pendientes = interface(IDAStronglyTypedDataTable)
|
IPedidosProveedor_Articulos_Pendientes = interface(IDAStronglyTypedDataTable)
|
||||||
['{34BDDF31-970F-4F58-923B-1C0E66F27A5F}']
|
['{0F474AE2-91D1-4747-B9B7-3825145A2CE3}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetID_PEDIDOValue: Integer;
|
function GetID_PEDIDOValue: Integer;
|
||||||
procedure SetID_PEDIDOValue(const aValue: Integer);
|
procedure SetID_PEDIDOValue(const aValue: Integer);
|
||||||
@ -917,39 +874,6 @@ implementation
|
|||||||
|
|
||||||
uses Variants, uROBinaryHelpers;
|
uses Variants, uROBinaryHelpers;
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
constructor TDarReferenciaDataTableRules.Create(aDataTable: TDADataTable);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaDataTableRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].AsString;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsString := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORIsNull: boolean;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].IsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsVariant := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TPedidosProveedorDataTableRules }
|
{ TPedidosProveedorDataTableRules }
|
||||||
constructor TPedidosProveedorDataTableRules.Create(aDataTable: TDADataTable);
|
constructor TPedidosProveedorDataTableRules.Create(aDataTable: TDADataTable);
|
||||||
var
|
var
|
||||||
@ -2154,7 +2078,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterDataTableRules(RID_DarReferencia, TDarReferenciaDataTableRules);
|
|
||||||
RegisterDataTableRules(RID_PedidosProveedor, TPedidosProveedorDataTableRules);
|
RegisterDataTableRules(RID_PedidosProveedor, TPedidosProveedorDataTableRules);
|
||||||
RegisterDataTableRules(RID_PedidosProveedor_Detalles, TPedidosProveedor_DetallesDataTableRules);
|
RegisterDataTableRules(RID_PedidosProveedor_Detalles, TPedidosProveedor_DetallesDataTableRules);
|
||||||
RegisterDataTableRules(RID_PedidosProveedor_Articulos_Pendientes, TPedidosProveedor_Articulos_PendientesDataTableRules);
|
RegisterDataTableRules(RID_PedidosProveedor_Articulos_Pendientes, TPedidosProveedor_Articulos_PendientesDataTableRules);
|
||||||
|
|||||||
@ -9,49 +9,14 @@ const
|
|||||||
{ Delta rules ids
|
{ Delta rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferenciaDelta = '{A1F1C534-FD91-42C1-856B-0CAE9DE48B68}';
|
RID_PedidosProveedorDelta = '{6B35580D-7178-4FFA-B9D7-5267221E9EC2}';
|
||||||
RID_PedidosProveedorDelta = '{349D50BE-57FD-468A-8751-0374A571AAA4}';
|
RID_PedidosProveedor_DetallesDelta = '{D3FC4AC8-B811-4DEF-B9E5-7EDF82012F3D}';
|
||||||
RID_PedidosProveedor_DetallesDelta = '{E924668B-8D1B-44C3-9DA2-D033F8C44E06}';
|
RID_PedidosProveedor_Articulos_PendientesDelta = '{CACE01FB-F88B-48FB-9693-CF3432BAF0D6}';
|
||||||
RID_PedidosProveedor_Articulos_PendientesDelta = '{0B859C3A-9F82-4451-A206-24CEF18A61E9}';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferenciaDelta }
|
|
||||||
IDarReferenciaDelta = interface(IDarReferencia)
|
|
||||||
['{A1F1C534-FD91-42C1-856B-0CAE9DE48B68}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetOldVALORValue : String;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
TDarReferenciaBusinessProcessorRules = class(TDABusinessProcessorRules, IDarReferencia, IDarReferenciaDelta)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
function GetOldVALORValue: String; virtual;
|
|
||||||
function GetOldVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR : String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull : Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
property OldVALORIsNull : Boolean read GetOldVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aBusinessProcessor: TDABusinessProcessor); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IPedidosProveedorDelta }
|
{ IPedidosProveedorDelta }
|
||||||
IPedidosProveedorDelta = interface(IPedidosProveedor)
|
IPedidosProveedorDelta = interface(IPedidosProveedor)
|
||||||
['{349D50BE-57FD-468A-8751-0374A571AAA4}']
|
['{6B35580D-7178-4FFA-B9D7-5267221E9EC2}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_EMPRESAValue : Integer;
|
function GetOldID_EMPRESAValue : Integer;
|
||||||
@ -495,7 +460,7 @@ type
|
|||||||
|
|
||||||
{ IPedidosProveedor_DetallesDelta }
|
{ IPedidosProveedor_DetallesDelta }
|
||||||
IPedidosProveedor_DetallesDelta = interface(IPedidosProveedor_Detalles)
|
IPedidosProveedor_DetallesDelta = interface(IPedidosProveedor_Detalles)
|
||||||
['{E924668B-8D1B-44C3-9DA2-D033F8C44E06}']
|
['{D3FC4AC8-B811-4DEF-B9E5-7EDF82012F3D}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_PEDIDOValue : Integer;
|
function GetOldID_PEDIDOValue : Integer;
|
||||||
@ -685,7 +650,7 @@ type
|
|||||||
|
|
||||||
{ IPedidosProveedor_Articulos_PendientesDelta }
|
{ IPedidosProveedor_Articulos_PendientesDelta }
|
||||||
IPedidosProveedor_Articulos_PendientesDelta = interface(IPedidosProveedor_Articulos_Pendientes)
|
IPedidosProveedor_Articulos_PendientesDelta = interface(IPedidosProveedor_Articulos_Pendientes)
|
||||||
['{0B859C3A-9F82-4451-A206-24CEF18A61E9}']
|
['{CACE01FB-F88B-48FB-9693-CF3432BAF0D6}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldID_PEDIDOValue : Integer;
|
function GetOldID_PEDIDOValue : Integer;
|
||||||
function GetOldREFERENCIAValue : String;
|
function GetOldREFERENCIAValue : String;
|
||||||
@ -782,49 +747,6 @@ implementation
|
|||||||
uses
|
uses
|
||||||
Variants, uROBinaryHelpers, uDAInterfaces;
|
Variants, uROBinaryHelpers, uDAInterfaces;
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
constructor TDarReferenciaBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaBusinessProcessorRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TPedidosProveedorBusinessProcessorRules }
|
{ TPedidosProveedorBusinessProcessorRules }
|
||||||
constructor TPedidosProveedorBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
constructor TPedidosProveedorBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
||||||
var
|
var
|
||||||
@ -2581,7 +2503,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(RID_DarReferenciaDelta, TDarReferenciaBusinessProcessorRules);
|
|
||||||
RegisterBusinessProcessorRules(RID_PedidosProveedorDelta, TPedidosProveedorBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_PedidosProveedorDelta, TPedidosProveedorBusinessProcessorRules);
|
||||||
RegisterBusinessProcessorRules(RID_PedidosProveedor_DetallesDelta, TPedidosProveedor_DetallesBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_PedidosProveedor_DetallesDelta, TPedidosProveedor_DetallesBusinessProcessorRules);
|
||||||
RegisterBusinessProcessorRules(RID_PedidosProveedor_Articulos_PendientesDelta, TPedidosProveedor_Articulos_PendientesBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_PedidosProveedor_Articulos_PendientesDelta, TPedidosProveedor_Articulos_PendientesBusinessProcessorRules);
|
||||||
|
|||||||
@ -8,67 +8,95 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
BIZ_SERVER_PEDIDOS_PROVEEDOR = 'Server.PedidosProveedor';
|
BIZ_SERVER_PEDIDOS_PROVEEDOR = 'Server.PedidosProveedor';
|
||||||
REF_PEDIDOS_PROVEEDOR = 'REF_PEDIDOS_PROVEEDOR';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TBizPedidosProveedorServer = class(TPedidosProveedorBusinessProcessorRules)
|
TBizPedidosProveedorServer = class(TPedidosProveedorBusinessProcessorRules)
|
||||||
|
private
|
||||||
|
FReferenciaAutomatica : Boolean;
|
||||||
|
function DarReferencia : String;
|
||||||
|
function IncrementarReferencia : Boolean;
|
||||||
protected
|
protected
|
||||||
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
|
||||||
|
const aDelta: IDADelta); override;
|
||||||
|
procedure AfterProcessChange(Sender: TDABusinessProcessor;
|
||||||
|
aChange: TDADeltaChange; Processed: Boolean;
|
||||||
|
var CanRemoveFromDelta: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
||||||
schPedidosProveedorClient_Intf;
|
schPedidosProveedorClient_Intf, srvReferencias_Impl;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_PEDIDOS_PROVEEDOR = 'REF_PEDIDOS_PROVEEDOR';
|
||||||
|
|
||||||
|
|
||||||
{ TBizPedidosProveedorServer }
|
{ TBizPedidosProveedorServer }
|
||||||
|
|
||||||
procedure TBizPedidosProveedorServer.BeforeProcessDelta(
|
procedure TBizPedidosProveedorServer.AfterProcessChange(
|
||||||
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
|
||||||
var
|
var CanRemoveFromDelta: Boolean);
|
||||||
ASchema : TDASchema;
|
|
||||||
ACurrentConn : IDAConnection;
|
|
||||||
dsData: IDADataset;
|
|
||||||
Empresa : Variant;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
{ Por defecto, no es necesario mantener los deltas una vez
|
||||||
|
procesados los cambios. }
|
||||||
|
CanRemoveFromDelta := True;
|
||||||
|
|
||||||
|
case aChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferencia;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
{ En este caso no debemos quitar los deltas porque
|
||||||
|
el cliente tiene que enterarse de la referencia que
|
||||||
|
ha rellenado el servidor. }
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBizPedidosProveedorServer.BeforeProcessDelta(
|
||||||
|
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
||||||
|
begin
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
|
||||||
case Sender.CurrentChange.ChangeType of
|
case Sender.CurrentChange.ChangeType of
|
||||||
ctInsert, ctUpdate: begin
|
ctInsert, ctUpdate: begin
|
||||||
//Si la referencia no ha sido asignada le asignamos una nosotros
|
//Si la referencia no ha sido asignada le asignamos una nosotros
|
||||||
if (VarIsNull(Sender.CurrentChange.NewValueByName[fld_PedidosProveedorREFERENCIA]))
|
if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then
|
||||||
or (VarToStr(Sender.CurrentChange.NewValueByName[fld_PedidosProveedorREFERENCIA]) = '') then
|
|
||||||
begin
|
begin
|
||||||
ASchema := BusinessProcessor.Schema;
|
FReferenciaAutomatica := True;
|
||||||
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
|
REFERENCIA := DarReferencia;
|
||||||
|
|
||||||
try
|
|
||||||
//Siempre va a estar rellena
|
|
||||||
Empresa := Sender.CurrentChange.NewValueByName[fld_PedidosProveedorID_EMPRESA];
|
|
||||||
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_PEDIDOS_PROVEEDOR, Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('No existe la tabla REFERENCIAS');
|
|
||||||
end;
|
|
||||||
|
|
||||||
dsData.Active := True;
|
|
||||||
|
|
||||||
if dsData.IsEmpty then
|
|
||||||
RaiseError('NO HAY REFERENCIA ' + REF_PEDIDOS_PROVEEDOR + ' DECLARADA EN TABLA REFERENCIAS');
|
|
||||||
|
|
||||||
REFERENCIA := dsData.FieldByName(fld_DarReferenciaVALOR).AsString;
|
|
||||||
|
|
||||||
try
|
|
||||||
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'EMPRESA'], [REF_PEDIDOS_PROVEEDOR, DarReferenciaSiguiente(REFERENCIA), Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla');
|
|
||||||
end;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizPedidosProveedorServer.DarReferencia: String;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(REF_PEDIDOS_PROVEEDOR, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBizPedidosProveedorServer.IncrementarReferencia: Boolean;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(REF_PEDIDOS_PROVEEDOR,
|
||||||
|
Self.REFERENCIA, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(BIZ_SERVER_PEDIDOS_PROVEEDOR, TBizPedidosProveedorServer);
|
RegisterBusinessProcessorRules(BIZ_SERVER_PEDIDOS_PROVEEDOR, TBizPedidosProveedorServer);
|
||||||
|
|
||||||
|
|||||||
@ -14,40 +14,6 @@ object srvPedidosProveedor: TsrvPedidosProveedor
|
|||||||
ConnectionManager = dmServer.ConnectionManager
|
ConnectionManager = dmServer.ConnectionManager
|
||||||
DataDictionary = DADataDictionary
|
DataDictionary = DADataDictionary
|
||||||
Datasets = <
|
Datasets = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'SELECT'#10' VALOR'#10'FROM'#10' REFERENCIAS'#10'WHERE'#10' CODIGO = :COD' +
|
|
||||||
'IGO'#10'AND ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <
|
|
||||||
item
|
|
||||||
DatasetField = 'VALOR'
|
|
||||||
TableField = 'VALOR'
|
|
||||||
end>
|
|
||||||
end>
|
|
||||||
Name = 'DarReferencia'
|
|
||||||
Fields = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
DataType = datString
|
|
||||||
Size = 255
|
|
||||||
end>
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <>
|
Params = <>
|
||||||
Statements = <
|
Statements = <
|
||||||
@ -619,32 +585,6 @@ object srvPedidosProveedor: TsrvPedidosProveedor
|
|||||||
JoinDataTables = <>
|
JoinDataTables = <>
|
||||||
UnionDataTables = <>
|
UnionDataTables = <>
|
||||||
Commands = <
|
Commands = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'UPDATE REFERENCIAS SET'#10' VALOR = :VALOR'#10'WHERE CODIGO = :COD' +
|
|
||||||
'IGO AND'#10' ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <>
|
|
||||||
end>
|
|
||||||
Name = 'ModificarReferencia'
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <
|
Params = <
|
||||||
item
|
item
|
||||||
|
|||||||
@ -9,21 +9,13 @@ const
|
|||||||
{ Data table rules ids
|
{ Data table rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferencia = '{6594B31A-A292-486E-A784-AF4659E1A953}';
|
RID_PresupuestosCliente = '{07B92F91-B78B-48C3-A022-A9DFF963F681}';
|
||||||
RID_PresupuestosCliente = '{13857C95-50E8-4EF5-8544-ABFCE393A83E}';
|
RID_PresupuestosCliente_Detalles = '{52E490B1-0AFF-4BBA-BA6A-CF8B547AFC33}';
|
||||||
RID_PresupuestosCliente_Detalles = '{FE4E1E48-710A-404F-B2DD-4547549B420D}';
|
|
||||||
|
|
||||||
{ Data table names }
|
{ Data table names }
|
||||||
nme_DarReferencia = 'DarReferencia';
|
|
||||||
nme_PresupuestosCliente = 'PresupuestosCliente';
|
nme_PresupuestosCliente = 'PresupuestosCliente';
|
||||||
nme_PresupuestosCliente_Detalles = 'PresupuestosCliente_Detalles';
|
nme_PresupuestosCliente_Detalles = 'PresupuestosCliente_Detalles';
|
||||||
|
|
||||||
{ DarReferencia fields }
|
|
||||||
fld_DarReferenciaVALOR = 'VALOR';
|
|
||||||
|
|
||||||
{ DarReferencia field indexes }
|
|
||||||
idx_DarReferenciaVALOR = 0;
|
|
||||||
|
|
||||||
{ PresupuestosCliente fields }
|
{ PresupuestosCliente fields }
|
||||||
fld_PresupuestosClienteID = 'ID';
|
fld_PresupuestosClienteID = 'ID';
|
||||||
fld_PresupuestosClienteID_EMPRESA = 'ID_EMPRESA';
|
fld_PresupuestosClienteID_EMPRESA = 'ID_EMPRESA';
|
||||||
@ -117,44 +109,9 @@ const
|
|||||||
idx_PresupuestosCliente_DetallesREFERENCIA_PROVEEDOR = 13;
|
idx_PresupuestosCliente_DetallesREFERENCIA_PROVEEDOR = 13;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferencia }
|
|
||||||
IDarReferencia = interface(IDAStronglyTypedDataTable)
|
|
||||||
['{D7753D57-71A2-4C4D-A580-8D58520FCFD3}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String;
|
|
||||||
procedure SetVALORValue(const aValue: String);
|
|
||||||
function GetVALORIsNull: Boolean;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean);
|
|
||||||
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
TDarReferenciaDataTableRules = class(TIntfObjectDADataTableRules, IDarReferencia)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aDataTable: TDADataTable); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IPresupuestosCliente }
|
{ IPresupuestosCliente }
|
||||||
IPresupuestosCliente = interface(IDAStronglyTypedDataTable)
|
IPresupuestosCliente = interface(IDAStronglyTypedDataTable)
|
||||||
['{4FCC9A5F-7A94-4A3A-940A-4CA0D4176EDB}']
|
['{89129FA5-5437-4FC5-A5F5-C5B6D0E115B1}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -513,7 +470,7 @@ type
|
|||||||
|
|
||||||
{ IPresupuestosCliente_Detalles }
|
{ IPresupuestosCliente_Detalles }
|
||||||
IPresupuestosCliente_Detalles = interface(IDAStronglyTypedDataTable)
|
IPresupuestosCliente_Detalles = interface(IDAStronglyTypedDataTable)
|
||||||
['{5B7F200F-3962-455D-98BB-A24DE98BD18B}']
|
['{5037407C-23C9-4C3D-A12B-66E966AAEB3A}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -706,39 +663,6 @@ implementation
|
|||||||
|
|
||||||
uses Variants, uROBinaryHelpers;
|
uses Variants, uROBinaryHelpers;
|
||||||
|
|
||||||
{ TDarReferenciaDataTableRules }
|
|
||||||
constructor TDarReferenciaDataTableRules.Create(aDataTable: TDADataTable);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaDataTableRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].AsString;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsString := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaDataTableRules.GetVALORIsNull: boolean;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_DarReferenciaVALOR].IsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaDataTableRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
DataTable.Fields[idx_DarReferenciaVALOR].AsVariant := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TPresupuestosClienteDataTableRules }
|
{ TPresupuestosClienteDataTableRules }
|
||||||
constructor TPresupuestosClienteDataTableRules.Create(aDataTable: TDADataTable);
|
constructor TPresupuestosClienteDataTableRules.Create(aDataTable: TDADataTable);
|
||||||
var
|
var
|
||||||
@ -1668,7 +1592,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterDataTableRules(RID_DarReferencia, TDarReferenciaDataTableRules);
|
|
||||||
RegisterDataTableRules(RID_PresupuestosCliente, TPresupuestosClienteDataTableRules);
|
RegisterDataTableRules(RID_PresupuestosCliente, TPresupuestosClienteDataTableRules);
|
||||||
RegisterDataTableRules(RID_PresupuestosCliente_Detalles, TPresupuestosCliente_DetallesDataTableRules);
|
RegisterDataTableRules(RID_PresupuestosCliente_Detalles, TPresupuestosCliente_DetallesDataTableRules);
|
||||||
|
|
||||||
|
|||||||
@ -9,48 +9,13 @@ const
|
|||||||
{ Delta rules ids
|
{ Delta rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_DarReferenciaDelta = '{0B34135E-0FB6-4CBA-AF23-A26B88542C10}';
|
RID_PresupuestosClienteDelta = '{33FBE0A4-6909-4581-81D2-E8717839296B}';
|
||||||
RID_PresupuestosClienteDelta = '{847B43BF-5186-406F-92E6-2135D35EF01F}';
|
RID_PresupuestosCliente_DetallesDelta = '{F84CCA1D-138D-4516-818D-EE1757D249B1}';
|
||||||
RID_PresupuestosCliente_DetallesDelta = '{1DA22D38-0DB5-450C-AF43-3F7F4D2EA56E}';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IDarReferenciaDelta }
|
|
||||||
IDarReferenciaDelta = interface(IDarReferencia)
|
|
||||||
['{0B34135E-0FB6-4CBA-AF23-A26B88542C10}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetOldVALORValue : String;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
TDarReferenciaBusinessProcessorRules = class(TDABusinessProcessorRules, IDarReferencia, IDarReferenciaDelta)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
function GetOldVALORValue: String; virtual;
|
|
||||||
function GetOldVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR : String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull : Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
property OldVALORIsNull : Boolean read GetOldVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aBusinessProcessor: TDABusinessProcessor); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IPresupuestosClienteDelta }
|
{ IPresupuestosClienteDelta }
|
||||||
IPresupuestosClienteDelta = interface(IPresupuestosCliente)
|
IPresupuestosClienteDelta = interface(IPresupuestosCliente)
|
||||||
['{847B43BF-5186-406F-92E6-2135D35EF01F}']
|
['{33FBE0A4-6909-4581-81D2-E8717839296B}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_EMPRESAValue : Integer;
|
function GetOldID_EMPRESAValue : Integer;
|
||||||
@ -412,7 +377,7 @@ type
|
|||||||
|
|
||||||
{ IPresupuestosCliente_DetallesDelta }
|
{ IPresupuestosCliente_DetallesDelta }
|
||||||
IPresupuestosCliente_DetallesDelta = interface(IPresupuestosCliente_Detalles)
|
IPresupuestosCliente_DetallesDelta = interface(IPresupuestosCliente_Detalles)
|
||||||
['{1DA22D38-0DB5-450C-AF43-3F7F4D2EA56E}']
|
['{F84CCA1D-138D-4516-818D-EE1757D249B1}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_PRESUPUESTOValue : Integer;
|
function GetOldID_PRESUPUESTOValue : Integer;
|
||||||
@ -605,49 +570,6 @@ implementation
|
|||||||
uses
|
uses
|
||||||
Variants, uROBinaryHelpers, uDAInterfaces;
|
Variants, uROBinaryHelpers, uDAInterfaces;
|
||||||
|
|
||||||
{ TDarReferenciaBusinessProcessorRules }
|
|
||||||
constructor TDarReferenciaBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TDarReferenciaBusinessProcessorRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDarReferenciaBusinessProcessorRules.GetOldVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_DarReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TDarReferenciaBusinessProcessorRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_DarReferenciaVALOR] := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TPresupuestosClienteBusinessProcessorRules }
|
{ TPresupuestosClienteBusinessProcessorRules }
|
||||||
constructor TPresupuestosClienteBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
constructor TPresupuestosClienteBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
||||||
var
|
var
|
||||||
@ -2001,7 +1923,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(RID_DarReferenciaDelta, TDarReferenciaBusinessProcessorRules);
|
|
||||||
RegisterBusinessProcessorRules(RID_PresupuestosClienteDelta, TPresupuestosClienteBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_PresupuestosClienteDelta, TPresupuestosClienteBusinessProcessorRules);
|
||||||
RegisterBusinessProcessorRules(RID_PresupuestosCliente_DetallesDelta, TPresupuestosCliente_DetallesBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_PresupuestosCliente_DetallesDelta, TPresupuestosCliente_DetallesBusinessProcessorRules);
|
||||||
|
|
||||||
|
|||||||
@ -8,68 +8,96 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
BIZ_SERVER_PRESUPUESTOS_CLIENTE = 'Server.PresupuestosCliente';
|
BIZ_SERVER_PRESUPUESTOS_CLIENTE = 'Server.PresupuestosCliente';
|
||||||
REF_PRESUPUESTOS_CLIENTE = 'REF_PRESUPUESTOS_CLIENTE';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TBizPresupuestosClienteServer = class(TPresupuestosClienteBusinessProcessorRules)
|
TBizPresupuestosClienteServer = class(TPresupuestosClienteBusinessProcessorRules)
|
||||||
|
private
|
||||||
|
FReferenciaAutomatica : Boolean;
|
||||||
|
function DarReferencia : String;
|
||||||
|
function IncrementarReferencia : Boolean;
|
||||||
protected
|
protected
|
||||||
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
|
||||||
|
const aDelta: IDADelta); override;
|
||||||
|
procedure AfterProcessChange(Sender: TDABusinessProcessor;
|
||||||
|
aChange: TDADeltaChange; Processed: Boolean;
|
||||||
|
var CanRemoveFromDelta: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
||||||
schPresupuestosClienteClient_Intf;
|
schPresupuestosClienteClient_Intf, srvReferencias_Impl;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_PRESUPUESTOS_CLIENTE = 'REF_PRESUPUESTOS_CLIENTE';
|
||||||
|
|
||||||
{ TBizPresupuestosClienteServer }
|
{ TBizPresupuestosClienteServer }
|
||||||
|
|
||||||
procedure TBizPresupuestosClienteServer.BeforeProcessDelta(
|
procedure TBizPresupuestosClienteServer.AfterProcessChange(
|
||||||
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
|
||||||
var
|
var CanRemoveFromDelta: Boolean);
|
||||||
ASchema : TDASchema;
|
|
||||||
ACurrentConn : IDAConnection;
|
|
||||||
dsData: IDADataset;
|
|
||||||
Empresa : Variant;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
{ Por defecto, no es necesario mantener los deltas una vez
|
||||||
|
procesados los cambios. }
|
||||||
|
CanRemoveFromDelta := True;
|
||||||
|
|
||||||
|
case aChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferencia;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
{ En este caso no debemos quitar los deltas porque
|
||||||
|
el cliente tiene que enterarse de la referencia que
|
||||||
|
ha rellenado el servidor. }
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBizPresupuestosClienteServer.BeforeProcessDelta(
|
||||||
|
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
|
||||||
case Sender.CurrentChange.ChangeType of
|
case Sender.CurrentChange.ChangeType of
|
||||||
ctInsert, ctUpdate: begin
|
ctInsert, ctUpdate: begin
|
||||||
//Si la referencia no ha sido asignada le asignamos una nosotros
|
//Si la referencia no ha sido asignada le asignamos una nosotros
|
||||||
if (VarIsNull(Sender.CurrentChange.NewValueByName[fld_PresupuestosClienteREFERENCIA]))
|
if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then
|
||||||
or (VarToStr(Sender.CurrentChange.NewValueByName[fld_PresupuestosClienteREFERENCIA]) = '') then
|
|
||||||
begin
|
begin
|
||||||
ASchema := BusinessProcessor.Schema;
|
FReferenciaAutomatica := True;
|
||||||
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
|
REFERENCIA := DarReferencia;
|
||||||
|
|
||||||
try
|
|
||||||
//Siempre va a estar rellena
|
|
||||||
Empresa := Sender.CurrentChange.NewValueByName[fld_PresupuestosClienteID_EMPRESA];
|
|
||||||
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_PRESUPUESTOS_CLIENTE, Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('No existe la tabla REFERENCIAS');
|
|
||||||
end;
|
|
||||||
|
|
||||||
dsData.Active := True;
|
|
||||||
|
|
||||||
if dsData.IsEmpty then
|
|
||||||
RaiseError('NO HAY REFERENCIA ' + REF_PRESUPUESTOS_CLIENTE + ' DECLARADA EN TABLA REFERENCIAS');
|
|
||||||
|
|
||||||
REFERENCIA := dsData.FieldByName(fld_DarReferenciaVALOR).AsString;
|
|
||||||
|
|
||||||
try
|
|
||||||
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'EMPRESA'], [REF_PRESUPUESTOS_CLIENTE, DarReferenciaSiguiente(REFERENCIA), Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla');
|
|
||||||
end;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizPresupuestosClienteServer.DarReferencia: String;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(REF_PRESUPUESTOS_CLIENTE, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBizPresupuestosClienteServer.IncrementarReferencia: Boolean;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(REF_PRESUPUESTOS_CLIENTE,
|
||||||
|
Self.REFERENCIA, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(BIZ_SERVER_PRESUPUESTOS_CLIENTE, TBizPresupuestosClienteServer);
|
RegisterBusinessProcessorRules(BIZ_SERVER_PRESUPUESTOS_CLIENTE, TBizPresupuestosClienteServer);
|
||||||
|
|
||||||
|
|||||||
@ -12,43 +12,6 @@ object srvPresupuestosCliente: TsrvPresupuestosCliente
|
|||||||
ConnectionManager = dmServer.ConnectionManager
|
ConnectionManager = dmServer.ConnectionManager
|
||||||
DataDictionary = DADataDictionary
|
DataDictionary = DADataDictionary
|
||||||
Datasets = <
|
Datasets = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
ParamType = daptInput
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
ConnectionType = 'Interbase'
|
|
||||||
Default = True
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
Name = 'IBX'
|
|
||||||
SQL =
|
|
||||||
'SELECT VALOR'#10'FROM REFERENCIAS'#10'WHERE CODIGO = :CODIGO'#10'AND ID_EMPR' +
|
|
||||||
'ESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <
|
|
||||||
item
|
|
||||||
DatasetField = 'VALOR'
|
|
||||||
TableField = 'VALOR'
|
|
||||||
end>
|
|
||||||
end>
|
|
||||||
Name = 'DarReferencia'
|
|
||||||
Fields = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
DataType = datString
|
|
||||||
Size = 255
|
|
||||||
end>
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <>
|
Params = <>
|
||||||
Statements = <
|
Statements = <
|
||||||
@ -486,34 +449,6 @@ object srvPresupuestosCliente: TsrvPresupuestosCliente
|
|||||||
JoinDataTables = <>
|
JoinDataTables = <>
|
||||||
UnionDataTables = <>
|
UnionDataTables = <>
|
||||||
Commands = <
|
Commands = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
ConnectionType = 'Interbase'
|
|
||||||
Default = True
|
|
||||||
Name = 'IBX'
|
|
||||||
SQL =
|
|
||||||
'UPDATE REFERENCIAS SET'#10' VALOR = :VALOR'#10'WHERE CODIGO = :COD' +
|
|
||||||
'IGO AND'#10' ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <>
|
|
||||||
end>
|
|
||||||
Name = 'ModificarReferencia'
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <
|
Params = <
|
||||||
item
|
item
|
||||||
|
|||||||
@ -31,7 +31,6 @@ type
|
|||||||
procedure DARemoteServiceBeforeGetDatasetData(const Dataset: IDADataset;
|
procedure DARemoteServiceBeforeGetDatasetData(const Dataset: IDADataset;
|
||||||
const IncludeSchema: Boolean; const MaxRecords: Integer);
|
const IncludeSchema: Boolean; const MaxRecords: Integer);
|
||||||
procedure DARemoteServiceCreate(Sender: TObject);
|
procedure DARemoteServiceCreate(Sender: TObject);
|
||||||
private
|
|
||||||
protected
|
protected
|
||||||
{ IsrvPresupuestosCliente methods }
|
{ IsrvPresupuestosCliente methods }
|
||||||
function GenerateReport(const ID: String): Binary;
|
function GenerateReport(const ID: String): Binary;
|
||||||
|
|||||||
@ -9,19 +9,11 @@ const
|
|||||||
{ Data table rules ids
|
{ Data table rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_darReferencia = '{2A669FBE-2DE4-4257-8CA5-518E3E7FE0A3}';
|
RID_RemesasCliente = '{A3A37A96-7559-4E50-8495-1079545939AD}';
|
||||||
RID_RemesasCliente = '{6AD59CC0-CB4B-4B42-87E9-0C30BF117732}';
|
|
||||||
|
|
||||||
{ Data table names }
|
{ Data table names }
|
||||||
nme_darReferencia = 'darReferencia';
|
|
||||||
nme_RemesasCliente = 'RemesasCliente';
|
nme_RemesasCliente = 'RemesasCliente';
|
||||||
|
|
||||||
{ darReferencia fields }
|
|
||||||
fld_darReferenciaVALOR = 'VALOR';
|
|
||||||
|
|
||||||
{ darReferencia field indexes }
|
|
||||||
idx_darReferenciaVALOR = 0;
|
|
||||||
|
|
||||||
{ RemesasCliente fields }
|
{ RemesasCliente fields }
|
||||||
fld_RemesasClienteID = 'ID';
|
fld_RemesasClienteID = 'ID';
|
||||||
fld_RemesasClienteID_EMPRESA = 'ID_EMPRESA';
|
fld_RemesasClienteID_EMPRESA = 'ID_EMPRESA';
|
||||||
@ -63,44 +55,9 @@ const
|
|||||||
idx_RemesasClienteIMPORTE_TOTAL = 17;
|
idx_RemesasClienteIMPORTE_TOTAL = 17;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IdarReferencia }
|
|
||||||
IdarReferencia = interface(IDAStronglyTypedDataTable)
|
|
||||||
['{41ABA49E-1EC4-40B5-8174-E851C8735EF6}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String;
|
|
||||||
procedure SetVALORValue(const aValue: String);
|
|
||||||
function GetVALORIsNull: Boolean;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean);
|
|
||||||
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TdarReferenciaDataTableRules }
|
|
||||||
TdarReferenciaDataTableRules = class(TIntfObjectDADataTableRules, IdarReferencia)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aDataTable: TDADataTable); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IRemesasCliente }
|
{ IRemesasCliente }
|
||||||
IRemesasCliente = interface(IDAStronglyTypedDataTable)
|
IRemesasCliente = interface(IDAStronglyTypedDataTable)
|
||||||
['{2DFC502B-A484-4565-BFCB-F4A172BBF594}']
|
['{DB8F46E9-380C-4C70-ABE6-04E5B22CF7A7}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -341,39 +298,6 @@ implementation
|
|||||||
|
|
||||||
uses Variants, uROBinaryHelpers;
|
uses Variants, uROBinaryHelpers;
|
||||||
|
|
||||||
{ TdarReferenciaDataTableRules }
|
|
||||||
constructor TdarReferenciaDataTableRules.Create(aDataTable: TDADataTable);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TdarReferenciaDataTableRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaDataTableRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_darReferenciaVALOR].AsString;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TdarReferenciaDataTableRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
DataTable.Fields[idx_darReferenciaVALOR].AsString := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaDataTableRules.GetVALORIsNull: boolean;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_darReferenciaVALOR].IsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TdarReferenciaDataTableRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
DataTable.Fields[idx_darReferenciaVALOR].AsVariant := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TRemesasClienteDataTableRules }
|
{ TRemesasClienteDataTableRules }
|
||||||
constructor TRemesasClienteDataTableRules.Create(aDataTable: TDADataTable);
|
constructor TRemesasClienteDataTableRules.Create(aDataTable: TDADataTable);
|
||||||
begin
|
begin
|
||||||
@ -765,7 +689,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterDataTableRules(RID_darReferencia, TdarReferenciaDataTableRules);
|
|
||||||
RegisterDataTableRules(RID_RemesasCliente, TRemesasClienteDataTableRules);
|
RegisterDataTableRules(RID_RemesasCliente, TRemesasClienteDataTableRules);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
@ -9,47 +9,12 @@ const
|
|||||||
{ Delta rules ids
|
{ Delta rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_darReferenciaDelta = '{93BE415A-B388-496F-B435-1AA6D4F3535C}';
|
RID_RemesasClienteDelta = '{DF92284D-DA6F-4B1B-9E11-B808478A1CBD}';
|
||||||
RID_RemesasClienteDelta = '{090FFD4E-3541-40D8-9577-9A6BBB35ECEB}';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IdarReferenciaDelta }
|
|
||||||
IdarReferenciaDelta = interface(IdarReferencia)
|
|
||||||
['{93BE415A-B388-496F-B435-1AA6D4F3535C}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetOldVALORValue : String;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TdarReferenciaBusinessProcessorRules }
|
|
||||||
TdarReferenciaBusinessProcessorRules = class(TDABusinessProcessorRules, IdarReferencia, IdarReferenciaDelta)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
function GetOldVALORValue: String; virtual;
|
|
||||||
function GetOldVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR : String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull : Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
property OldVALORIsNull : Boolean read GetOldVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aBusinessProcessor: TDABusinessProcessor); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IRemesasClienteDelta }
|
{ IRemesasClienteDelta }
|
||||||
IRemesasClienteDelta = interface(IRemesasCliente)
|
IRemesasClienteDelta = interface(IRemesasCliente)
|
||||||
['{090FFD4E-3541-40D8-9577-9A6BBB35ECEB}']
|
['{DF92284D-DA6F-4B1B-9E11-B808478A1CBD}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_EMPRESAValue : Integer;
|
function GetOldID_EMPRESAValue : Integer;
|
||||||
@ -290,49 +255,6 @@ implementation
|
|||||||
uses
|
uses
|
||||||
Variants, uROBinaryHelpers, uDAInterfaces;
|
Variants, uROBinaryHelpers, uDAInterfaces;
|
||||||
|
|
||||||
{ TdarReferenciaBusinessProcessorRules }
|
|
||||||
constructor TdarReferenciaBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TdarReferenciaBusinessProcessorRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaBusinessProcessorRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.NewValueByName[fld_darReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaBusinessProcessorRules.GetVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_darReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaBusinessProcessorRules.GetOldVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.OldValueByName[fld_darReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaBusinessProcessorRules.GetOldVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_darReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TdarReferenciaBusinessProcessorRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_darReferenciaVALOR] := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TdarReferenciaBusinessProcessorRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_darReferenciaVALOR] := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TRemesasClienteBusinessProcessorRules }
|
{ TRemesasClienteBusinessProcessorRules }
|
||||||
constructor TRemesasClienteBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
constructor TRemesasClienteBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
||||||
begin
|
begin
|
||||||
@ -904,7 +826,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(RID_darReferenciaDelta, TdarReferenciaBusinessProcessorRules);
|
|
||||||
RegisterBusinessProcessorRules(RID_RemesasClienteDelta, TRemesasClienteBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_RemesasClienteDelta, TRemesasClienteBusinessProcessorRules);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
@ -8,69 +8,94 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
BIZ_SERVER_REMESAS_CLIENTE = 'Server.RemesasCliente';
|
BIZ_SERVER_REMESAS_CLIENTE = 'Server.RemesasCliente';
|
||||||
REF_REMESAS_CLIENTE = 'REF_REMESAS_CLIENTE';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TBizRemesasClienteServer = class(TRemesasClienteBusinessProcessorRules)
|
TBizRemesasClienteServer = class(TRemesasClienteBusinessProcessorRules)
|
||||||
|
private
|
||||||
|
FReferenciaAutomatica : Boolean;
|
||||||
|
function DarReferencia : String;
|
||||||
|
function IncrementarReferencia : Boolean;
|
||||||
protected
|
protected
|
||||||
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
|
||||||
|
const aDelta: IDADelta); override;
|
||||||
|
procedure AfterProcessChange(Sender: TDABusinessProcessor;
|
||||||
|
aChange: TDADeltaChange; Processed: Boolean;
|
||||||
|
var CanRemoveFromDelta: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
||||||
schRemesasClienteClient_Intf;
|
schRemesasClienteClient_Intf, srvReferencias_Impl;
|
||||||
|
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_REMESAS_CLIENTE = 'REF_REMESAS_CLIENTE';
|
||||||
|
|
||||||
{ TBizRemesasClienteServer }
|
{ TBizRemesasClienteServer }
|
||||||
|
|
||||||
|
procedure TBizRemesasClienteServer.AfterProcessChange(
|
||||||
|
Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
|
||||||
|
var CanRemoveFromDelta: Boolean);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
{ Por defecto, no es necesario mantener los deltas una vez
|
||||||
|
procesados los cambios. }
|
||||||
|
CanRemoveFromDelta := True;
|
||||||
|
|
||||||
|
case aChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferencia;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
{ En este caso no debemos quitar los deltas porque
|
||||||
|
el cliente tiene que enterarse de la referencia que
|
||||||
|
ha rellenado el servidor. }
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBizRemesasClienteServer.BeforeProcessDelta(
|
procedure TBizRemesasClienteServer.BeforeProcessDelta(
|
||||||
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
||||||
var
|
|
||||||
ASchema : TDASchema;
|
|
||||||
ACurrentConn : IDAConnection;
|
|
||||||
dsData: IDADataset;
|
|
||||||
Empresa : Variant;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited;
|
FReferenciaAutomatica := False;
|
||||||
|
|
||||||
case Sender.CurrentChange.ChangeType of
|
case Sender.CurrentChange.ChangeType of
|
||||||
ctInsert, ctUpdate: begin
|
ctInsert, ctUpdate: begin
|
||||||
//Si la referencia no ha sido asignada le asignamos una nosotros
|
//Si la referencia no ha sido asignada le asignamos una nosotros
|
||||||
if (VarIsNull(Sender.CurrentChange.NewValueByName[fld_RemesasClienteREFERENCIA]))
|
if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then
|
||||||
or (VarToStr(Sender.CurrentChange.NewValueByName[fld_RemesasClienteREFERENCIA]) = '') then
|
|
||||||
begin
|
begin
|
||||||
ASchema := BusinessProcessor.Schema;
|
FReferenciaAutomatica := True;
|
||||||
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
|
REFERENCIA := DarReferencia;
|
||||||
|
|
||||||
try
|
|
||||||
//Siempre va a estar rellena
|
|
||||||
Empresa := Sender.CurrentChange.NewValueByName[fld_RemesasClienteID_EMPRESA];
|
|
||||||
|
|
||||||
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_REMESAS_CLIENTE, Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('No existe la tabla REFERENCIAS');
|
|
||||||
end;
|
|
||||||
|
|
||||||
dsData.Active := True;
|
|
||||||
|
|
||||||
if dsData.IsEmpty then
|
|
||||||
RaiseError('NO HAY REFERENCIA ' + REF_REMESAS_CLIENTE + ' DECLARADA EN TABLA REFERENCIAS');
|
|
||||||
|
|
||||||
REFERENCIA := dsData.FieldByName('VALOR').AsString;
|
|
||||||
|
|
||||||
try
|
|
||||||
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'ID_EMPRESA'], [REF_Remesas_CLIENTE, DarReferenciaSiguiente(REFERENCIA), Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla');
|
|
||||||
end;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizRemesasClienteServer.DarReferencia: String;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(REF_REMESAS_CLIENTE, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBizRemesasClienteServer.IncrementarReferencia: Boolean;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(REF_REMESAS_CLIENTE,
|
||||||
|
Self.REFERENCIA, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(BIZ_SERVER_REMESAS_CLIENTE, TBizRemesasClienteServer);
|
RegisterBusinessProcessorRules(BIZ_SERVER_REMESAS_CLIENTE, TBizRemesasClienteServer);
|
||||||
|
|
||||||
|
|||||||
@ -136,42 +136,6 @@ object srvRemesasCliente: TsrvRemesasCliente
|
|||||||
DataDictionary = DataDictionary
|
DataDictionary = DataDictionary
|
||||||
Diagrams = Diagrams
|
Diagrams = Diagrams
|
||||||
Datasets = <
|
Datasets = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
DataType = datString
|
|
||||||
Size = 50
|
|
||||||
Value = 'REF_REMESAS_CLIENTE'
|
|
||||||
ParamType = daptInput
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = '1'
|
|
||||||
ParamType = daptInput
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'SELECT VALOR'#10'FROM REFERENCIAS'#10'WHERE CODIGO = :CODIGO'#10'AND ID_EMPR' +
|
|
||||||
'ESA = :EMPRESA'
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <
|
|
||||||
item
|
|
||||||
DatasetField = 'VALOR'
|
|
||||||
TableField = 'VALOR'
|
|
||||||
end>
|
|
||||||
end>
|
|
||||||
Name = 'darReferencia'
|
|
||||||
Fields = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
DataType = datString
|
|
||||||
Size = 255
|
|
||||||
end>
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <>
|
Params = <>
|
||||||
Statements = <
|
Statements = <
|
||||||
@ -363,32 +327,6 @@ object srvRemesasCliente: TsrvRemesasCliente
|
|||||||
JoinDataTables = <>
|
JoinDataTables = <>
|
||||||
UnionDataTables = <>
|
UnionDataTables = <>
|
||||||
Commands = <
|
Commands = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'UPDATE REFERENCIAS SET'#10' VALOR = :VALOR'#10'WHERE CODIGO = :COD' +
|
|
||||||
'IGO AND'#10' ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <>
|
|
||||||
end>
|
|
||||||
Name = 'ModificarReferencia'
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <
|
Params = <
|
||||||
item
|
item
|
||||||
|
|||||||
@ -23,9 +23,9 @@ type
|
|||||||
TsrvRemesasCliente = class(TDataAbstractService, IsrvRemesasCliente)
|
TsrvRemesasCliente = class(TDataAbstractService, IsrvRemesasCliente)
|
||||||
Diagrams: TDADiagrams;
|
Diagrams: TDADiagrams;
|
||||||
bpRemesasCliente: TDABusinessProcessor;
|
bpRemesasCliente: TDABusinessProcessor;
|
||||||
|
Bin2DataStreamer: TDABin2DataStreamer;
|
||||||
schRemesasCliente: TDASchema;
|
schRemesasCliente: TDASchema;
|
||||||
DataDictionary: TDADataDictionary;
|
DataDictionary: TDADataDictionary;
|
||||||
Bin2DataStreamer: TDABin2DataStreamer;
|
|
||||||
procedure DARemoteServiceCreate(Sender: TObject);
|
procedure DARemoteServiceCreate(Sender: TObject);
|
||||||
procedure DARemoteServiceBeforeGetDatasetData(const Dataset: IDADataset;
|
procedure DARemoteServiceBeforeGetDatasetData(const Dataset: IDADataset;
|
||||||
const IncludeSchema: Boolean; const MaxRecords: Integer);
|
const IncludeSchema: Boolean; const MaxRecords: Integer);
|
||||||
|
|||||||
@ -9,19 +9,11 @@ const
|
|||||||
{ Data table rules ids
|
{ Data table rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_darReferencia = '{60F91383-6F77-4AD3-9E84-B27C782A1482}';
|
RID_RemesasProveedor = '{2EB3551B-D75C-4B29-8F57-BCF984FDBFC8}';
|
||||||
RID_RemesasProveedor = '{044A9E1D-90AB-4E1C-BFCB-98772BB603BE}';
|
|
||||||
|
|
||||||
{ Data table names }
|
{ Data table names }
|
||||||
nme_darReferencia = 'darReferencia';
|
|
||||||
nme_RemesasProveedor = 'RemesasProveedor';
|
nme_RemesasProveedor = 'RemesasProveedor';
|
||||||
|
|
||||||
{ darReferencia fields }
|
|
||||||
fld_darReferenciaVALOR = 'VALOR';
|
|
||||||
|
|
||||||
{ darReferencia field indexes }
|
|
||||||
idx_darReferenciaVALOR = 0;
|
|
||||||
|
|
||||||
{ RemesasProveedor fields }
|
{ RemesasProveedor fields }
|
||||||
fld_RemesasProveedorID = 'ID';
|
fld_RemesasProveedorID = 'ID';
|
||||||
fld_RemesasProveedorID_EMPRESA = 'ID_EMPRESA';
|
fld_RemesasProveedorID_EMPRESA = 'ID_EMPRESA';
|
||||||
@ -63,44 +55,9 @@ const
|
|||||||
idx_RemesasProveedorIMPORTE_TOTAL = 17;
|
idx_RemesasProveedorIMPORTE_TOTAL = 17;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IdarReferencia }
|
|
||||||
IdarReferencia = interface(IDAStronglyTypedDataTable)
|
|
||||||
['{3EC7EB36-5C81-4D96-924C-BFBAD8D38041}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String;
|
|
||||||
procedure SetVALORValue(const aValue: String);
|
|
||||||
function GetVALORIsNull: Boolean;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean);
|
|
||||||
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TdarReferenciaDataTableRules }
|
|
||||||
TdarReferenciaDataTableRules = class(TIntfObjectDADataTableRules, IdarReferencia)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR: String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull: Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aDataTable: TDADataTable); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IRemesasProveedor }
|
{ IRemesasProveedor }
|
||||||
IRemesasProveedor = interface(IDAStronglyTypedDataTable)
|
IRemesasProveedor = interface(IDAStronglyTypedDataTable)
|
||||||
['{33E0651A-D061-431F-9EAD-9B9B0458B888}']
|
['{C0DCF223-5495-4B6F-98BC-7C51719E7D34}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetIDValue: Integer;
|
function GetIDValue: Integer;
|
||||||
procedure SetIDValue(const aValue: Integer);
|
procedure SetIDValue(const aValue: Integer);
|
||||||
@ -341,39 +298,6 @@ implementation
|
|||||||
|
|
||||||
uses Variants, uROBinaryHelpers;
|
uses Variants, uROBinaryHelpers;
|
||||||
|
|
||||||
{ TdarReferenciaDataTableRules }
|
|
||||||
constructor TdarReferenciaDataTableRules.Create(aDataTable: TDADataTable);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TdarReferenciaDataTableRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaDataTableRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_darReferenciaVALOR].AsString;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TdarReferenciaDataTableRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
DataTable.Fields[idx_darReferenciaVALOR].AsString := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaDataTableRules.GetVALORIsNull: boolean;
|
|
||||||
begin
|
|
||||||
result := DataTable.Fields[idx_darReferenciaVALOR].IsNull;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TdarReferenciaDataTableRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
DataTable.Fields[idx_darReferenciaVALOR].AsVariant := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TRemesasProveedorDataTableRules }
|
{ TRemesasProveedorDataTableRules }
|
||||||
constructor TRemesasProveedorDataTableRules.Create(aDataTable: TDADataTable);
|
constructor TRemesasProveedorDataTableRules.Create(aDataTable: TDADataTable);
|
||||||
begin
|
begin
|
||||||
@ -765,7 +689,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterDataTableRules(RID_darReferencia, TdarReferenciaDataTableRules);
|
|
||||||
RegisterDataTableRules(RID_RemesasProveedor, TRemesasProveedorDataTableRules);
|
RegisterDataTableRules(RID_RemesasProveedor, TRemesasProveedorDataTableRules);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
@ -9,47 +9,12 @@ const
|
|||||||
{ Delta rules ids
|
{ Delta rules ids
|
||||||
Feel free to change them to something more human readable
|
Feel free to change them to something more human readable
|
||||||
but make sure they are unique in the context of your application }
|
but make sure they are unique in the context of your application }
|
||||||
RID_darReferenciaDelta = '{654CD172-ED14-43A0-85CD-7D5714EF6CA6}';
|
RID_RemesasProveedorDelta = '{8EF544D2-A579-49C7-A4AF-220B10067DE0}';
|
||||||
RID_RemesasProveedorDelta = '{66615F2E-3E7A-49C6-AE86-A922790A3D92}';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
{ IdarReferenciaDelta }
|
|
||||||
IdarReferenciaDelta = interface(IdarReferencia)
|
|
||||||
['{654CD172-ED14-43A0-85CD-7D5714EF6CA6}']
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetOldVALORValue : String;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TdarReferenciaBusinessProcessorRules }
|
|
||||||
TdarReferenciaBusinessProcessorRules = class(TDABusinessProcessorRules, IdarReferencia, IdarReferenciaDelta)
|
|
||||||
private
|
|
||||||
protected
|
|
||||||
{ Property getters and setters }
|
|
||||||
function GetVALORValue: String; virtual;
|
|
||||||
function GetVALORIsNull: Boolean; virtual;
|
|
||||||
function GetOldVALORValue: String; virtual;
|
|
||||||
function GetOldVALORIsNull: Boolean; virtual;
|
|
||||||
procedure SetVALORValue(const aValue: String); virtual;
|
|
||||||
procedure SetVALORIsNull(const aValue: Boolean); virtual;
|
|
||||||
|
|
||||||
{ Properties }
|
|
||||||
property VALOR : String read GetVALORValue write SetVALORValue;
|
|
||||||
property VALORIsNull : Boolean read GetVALORIsNull write SetVALORIsNull;
|
|
||||||
property OldVALOR : String read GetOldVALORValue;
|
|
||||||
property OldVALORIsNull : Boolean read GetOldVALORIsNull;
|
|
||||||
|
|
||||||
public
|
|
||||||
constructor Create(aBusinessProcessor: TDABusinessProcessor); override;
|
|
||||||
destructor Destroy; override;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ IRemesasProveedorDelta }
|
{ IRemesasProveedorDelta }
|
||||||
IRemesasProveedorDelta = interface(IRemesasProveedor)
|
IRemesasProveedorDelta = interface(IRemesasProveedor)
|
||||||
['{66615F2E-3E7A-49C6-AE86-A922790A3D92}']
|
['{8EF544D2-A579-49C7-A4AF-220B10067DE0}']
|
||||||
{ Property getters and setters }
|
{ Property getters and setters }
|
||||||
function GetOldIDValue : Integer;
|
function GetOldIDValue : Integer;
|
||||||
function GetOldID_EMPRESAValue : Integer;
|
function GetOldID_EMPRESAValue : Integer;
|
||||||
@ -290,49 +255,6 @@ implementation
|
|||||||
uses
|
uses
|
||||||
Variants, uROBinaryHelpers, uDAInterfaces;
|
Variants, uROBinaryHelpers, uDAInterfaces;
|
||||||
|
|
||||||
{ TdarReferenciaBusinessProcessorRules }
|
|
||||||
constructor TdarReferenciaBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
destructor TdarReferenciaBusinessProcessorRules.Destroy;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaBusinessProcessorRules.GetVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.NewValueByName[fld_darReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaBusinessProcessorRules.GetVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_darReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaBusinessProcessorRules.GetOldVALORValue: String;
|
|
||||||
begin
|
|
||||||
result := BusinessProcessor.CurrentChange.OldValueByName[fld_darReferenciaVALOR];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TdarReferenciaBusinessProcessorRules.GetOldVALORIsNull: Boolean;
|
|
||||||
begin
|
|
||||||
result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_darReferenciaVALOR]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TdarReferenciaBusinessProcessorRules.SetVALORValue(const aValue: String);
|
|
||||||
begin
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_darReferenciaVALOR] := aValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TdarReferenciaBusinessProcessorRules.SetVALORIsNull(const aValue: Boolean);
|
|
||||||
begin
|
|
||||||
if aValue then
|
|
||||||
BusinessProcessor.CurrentChange.NewValueByName[fld_darReferenciaVALOR] := Null;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ TRemesasProveedorBusinessProcessorRules }
|
{ TRemesasProveedorBusinessProcessorRules }
|
||||||
constructor TRemesasProveedorBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
constructor TRemesasProveedorBusinessProcessorRules.Create(aBusinessProcessor: TDABusinessProcessor);
|
||||||
begin
|
begin
|
||||||
@ -904,7 +826,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(RID_darReferenciaDelta, TdarReferenciaBusinessProcessorRules);
|
|
||||||
RegisterBusinessProcessorRules(RID_RemesasProveedorDelta, TRemesasProveedorBusinessProcessorRules);
|
RegisterBusinessProcessorRules(RID_RemesasProveedorDelta, TRemesasProveedorBusinessProcessorRules);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
@ -8,68 +8,95 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
BIZ_SERVER_REMESAS_Proveedor = 'Server.RemesasProveedor';
|
BIZ_SERVER_REMESAS_Proveedor = 'Server.RemesasProveedor';
|
||||||
REF_REMESAS_PROVEEDOR = 'REF_REMESAS_PROVEEDOR';
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TBizRemesasProveedorServer = class(TRemesasProveedorBusinessProcessorRules)
|
TBizRemesasProveedorServer = class(TRemesasProveedorBusinessProcessorRules)
|
||||||
|
private
|
||||||
|
FReferenciaAutomatica : Boolean;
|
||||||
|
function DarReferencia : String;
|
||||||
|
function IncrementarReferencia : Boolean;
|
||||||
protected
|
protected
|
||||||
procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override;
|
procedure BeforeProcessDelta(Sender: TDABusinessProcessor;
|
||||||
|
const aDelta: IDADelta); override;
|
||||||
|
procedure AfterProcessChange(Sender: TDABusinessProcessor;
|
||||||
|
aChange: TDADeltaChange; Processed: Boolean;
|
||||||
|
var CanRemoveFromDelta: Boolean); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
Variants, uDAClasses, uReferenciasUtils, uBusinessUtils, uROClasses, uDataModuleServer,
|
||||||
schRemesasProveedorClient_Intf;
|
schRemesasProveedorClient_Intf, srvReferencias_Impl;
|
||||||
|
|
||||||
|
const
|
||||||
|
REF_REMESAS_PROVEEDOR = 'REF_REMESAS_PROVEEDOR';
|
||||||
|
|
||||||
{ TBizRemesasProveedorServer }
|
{ TBizRemesasProveedorServer }
|
||||||
|
|
||||||
procedure TBizRemesasProveedorServer.BeforeProcessDelta(
|
procedure TBizRemesasProveedorServer.AfterProcessChange(
|
||||||
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean;
|
||||||
var
|
var CanRemoveFromDelta: Boolean);
|
||||||
ASchema : TDASchema;
|
|
||||||
ACurrentConn : IDAConnection;
|
|
||||||
dsData: IDADataset;
|
|
||||||
Empresa : Variant;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
{ Por defecto, no es necesario mantener los deltas una vez
|
||||||
|
procesados los cambios. }
|
||||||
|
CanRemoveFromDelta := True;
|
||||||
|
|
||||||
|
case aChange.ChangeType of
|
||||||
|
ctInsert, ctUpdate: begin
|
||||||
|
if FReferenciaAutomatica then
|
||||||
|
begin
|
||||||
|
IncrementarReferencia;
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
{ En este caso no debemos quitar los deltas porque
|
||||||
|
el cliente tiene que enterarse de la referencia que
|
||||||
|
ha rellenado el servidor. }
|
||||||
|
CanRemoveFromDelta := False;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBizRemesasProveedorServer.BeforeProcessDelta(
|
||||||
|
Sender: TDABusinessProcessor; const aDelta: IDADelta);
|
||||||
|
begin
|
||||||
|
FReferenciaAutomatica := False;
|
||||||
|
|
||||||
case Sender.CurrentChange.ChangeType of
|
case Sender.CurrentChange.ChangeType of
|
||||||
ctInsert, ctUpdate: begin
|
ctInsert, ctUpdate: begin
|
||||||
//Si la referencia no ha sido asignada le asignamos una nosotros
|
//Si la referencia no ha sido asignada le asignamos una nosotros
|
||||||
if (VarIsNull(Sender.CurrentChange.NewValueByName[fld_RemesasProveedorREFERENCIA]))
|
if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then
|
||||||
or (VarToStr(Sender.CurrentChange.NewValueByName[fld_RemesasProveedorREFERENCIA]) = '') then
|
|
||||||
begin
|
begin
|
||||||
ASchema := BusinessProcessor.Schema;
|
FReferenciaAutomatica := True;
|
||||||
ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor);
|
REFERENCIA := DarReferencia;
|
||||||
|
|
||||||
try
|
|
||||||
//Siempre va a estar rellena
|
|
||||||
Empresa := Sender.CurrentChange.NewValueByName[fld_RemesasProveedorID_EMPRESA];
|
|
||||||
|
|
||||||
dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_REMESAS_PROVEEDOR, Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('No existe la tabla REFERENCIAS');
|
|
||||||
end;
|
|
||||||
|
|
||||||
dsData.Active := True;
|
|
||||||
|
|
||||||
if dsData.IsEmpty then
|
|
||||||
RaiseError('NO HAY REFERENCIA ' + REF_REMESAS_PROVEEDOR + ' DECLARADA EN TABLA REFERENCIAS');
|
|
||||||
|
|
||||||
REFERENCIA := dsData.FieldByName('VALOR').AsString;
|
|
||||||
|
|
||||||
try
|
|
||||||
ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'ID_EMPRESA'], [REF_REMESAS_PROVEEDOR, DarReferenciaSiguiente(REFERENCIA), Empresa]);
|
|
||||||
except
|
|
||||||
RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla');
|
|
||||||
end;
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBizRemesasProveedorServer.DarReferencia: String;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := DarNuevaReferencia(REF_REMESAS_PROVEEDOR, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBizRemesasProveedorServer.IncrementarReferencia: Boolean;
|
||||||
|
begin
|
||||||
|
with TsrvReferencias.Create(NIL) do
|
||||||
|
try
|
||||||
|
Result := IncrementarValorReferencia(REF_REMESAS_PROVEEDOR,
|
||||||
|
Self.REFERENCIA, ID_EMPRESA)
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterBusinessProcessorRules(BIZ_SERVER_REMESAS_Proveedor, TBizRemesasProveedorServer);
|
RegisterBusinessProcessorRules(BIZ_SERVER_REMESAS_Proveedor, TBizRemesasProveedorServer);
|
||||||
|
|
||||||
|
|||||||
@ -136,42 +136,6 @@ object srvRemesasProveedor: TsrvRemesasProveedor
|
|||||||
DataDictionary = DataDictionary
|
DataDictionary = DataDictionary
|
||||||
Diagrams = Diagrams
|
Diagrams = Diagrams
|
||||||
Datasets = <
|
Datasets = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
DataType = datString
|
|
||||||
Size = 50
|
|
||||||
Value = 'REF_REMESAS_CLIENTE'
|
|
||||||
ParamType = daptInput
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = '1'
|
|
||||||
ParamType = daptInput
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'SELECT VALOR'#10'FROM REFERENCIAS'#10'WHERE CODIGO = :CODIGO'#10'AND ID_EMPR' +
|
|
||||||
'ESA = :EMPRESA'
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <
|
|
||||||
item
|
|
||||||
DatasetField = 'VALOR'
|
|
||||||
TableField = 'VALOR'
|
|
||||||
end>
|
|
||||||
end>
|
|
||||||
Name = 'darReferencia'
|
|
||||||
Fields = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
DataType = datString
|
|
||||||
Size = 255
|
|
||||||
end>
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <>
|
Params = <>
|
||||||
Statements = <
|
Statements = <
|
||||||
@ -363,32 +327,6 @@ object srvRemesasProveedor: TsrvRemesasProveedor
|
|||||||
JoinDataTables = <>
|
JoinDataTables = <>
|
||||||
UnionDataTables = <>
|
UnionDataTables = <>
|
||||||
Commands = <
|
Commands = <
|
||||||
item
|
|
||||||
Params = <
|
|
||||||
item
|
|
||||||
Name = 'VALOR'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'CODIGO'
|
|
||||||
Value = ''
|
|
||||||
end
|
|
||||||
item
|
|
||||||
Name = 'EMPRESA'
|
|
||||||
Value = ''
|
|
||||||
end>
|
|
||||||
Statements = <
|
|
||||||
item
|
|
||||||
Connection = 'IBX'
|
|
||||||
TargetTable = 'REFERENCIAS'
|
|
||||||
SQL =
|
|
||||||
'UPDATE REFERENCIAS SET'#10' VALOR = :VALOR'#10'WHERE CODIGO = :COD' +
|
|
||||||
'IGO AND'#10' ID_EMPRESA = :EMPRESA'#10
|
|
||||||
StatementType = stSQL
|
|
||||||
ColumnMappings = <>
|
|
||||||
end>
|
|
||||||
Name = 'ModificarReferencia'
|
|
||||||
end
|
|
||||||
item
|
item
|
||||||
Params = <
|
Params = <
|
||||||
item
|
item
|
||||||
|
|||||||
@ -23,9 +23,9 @@ type
|
|||||||
TsrvRemesasProveedor = class(TDataAbstractService, IsrvRemesasProveedor)
|
TsrvRemesasProveedor = class(TDataAbstractService, IsrvRemesasProveedor)
|
||||||
Diagrams: TDADiagrams;
|
Diagrams: TDADiagrams;
|
||||||
bpRemesasProveedor: TDABusinessProcessor;
|
bpRemesasProveedor: TDABusinessProcessor;
|
||||||
|
Bin2DataStreamer: TDABin2DataStreamer;
|
||||||
schRemesasProveedor: TDASchema;
|
schRemesasProveedor: TDASchema;
|
||||||
DataDictionary: TDADataDictionary;
|
DataDictionary: TDADataDictionary;
|
||||||
Bin2DataStreamer: TDABin2DataStreamer;
|
|
||||||
procedure DARemoteServiceCreate(Sender: TObject);
|
procedure DARemoteServiceCreate(Sender: TObject);
|
||||||
procedure DARemoteServiceBeforeGetDatasetData(const Dataset: IDADataset;
|
procedure DARemoteServiceBeforeGetDatasetData(const Dataset: IDADataset;
|
||||||
const IncludeSchema: Boolean; const MaxRecords: Integer);
|
const IncludeSchema: Boolean; const MaxRecords: Integer);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user