diff --git a/Source/ApplicationBase/ApplicationBase.res b/Source/ApplicationBase/ApplicationBase.res index 1641339..8b251f3 100644 Binary files a/Source/ApplicationBase/ApplicationBase.res and b/Source/ApplicationBase/ApplicationBase.res differ diff --git a/Source/ApplicationBase/Empresas/Controller/uDatosBancariosEmpresaController.pas b/Source/ApplicationBase/Empresas/Controller/uDatosBancariosEmpresaController.pas index ebdfe04..23ee298 100644 --- a/Source/ApplicationBase/Empresas/Controller/uDatosBancariosEmpresaController.pas +++ b/Source/ApplicationBase/Empresas/Controller/uDatosBancariosEmpresaController.pas @@ -10,6 +10,9 @@ uses type IDatosBancariosEmpresaController = interface(IControllerBase) ['{E9B0313E-7B16-420A-B47E-20E42E96BAC6}'] + function GenerarCodigoIBAN (ADatosBancarios : IBizEmpresasDatosBancarios) : string; + function ValidarCodigoIBAN (AIBAN : string) : boolean; + function ValidarDatosBancarios(ADatosBancarios : IBizEmpresasDatosBancarios; AEmpresa : IBizEmpresa): Boolean; procedure Ver(ADatosBancarios : IBizEmpresasDatosBancarios); end; @@ -18,7 +21,9 @@ type FDataModule : IDataModuleEmpresas; protected public - function ValidarDatosBancarios(ADatosBancarios : IBizEmpresasDatosBancarios; AEmpresa : IBizEmpresa): Boolean; virtual; + function GenerarCodigoIBAN (ADatosBancarios : IBizEmpresasDatosBancarios) : string; + function ValidarCodigoIBAN (AIBAN : string) : boolean; + function ValidarDatosBancarios(ADatosBancarios : IBizEmpresasDatosBancarios; AEmpresa : IBizEmpresa): Boolean; virtual; procedure Ver(ADatosBancarios : IBizEmpresasDatosBancarios); constructor Create; override; destructor Destroy; override; @@ -30,7 +35,7 @@ implementation uses uDataModuleEmpresas, schEmpresasClient_Intf, uIEditorDatosBancarioEmpresa, - uEditorRegistryUtils, cxControls, uIBANUtils; + uEditorRegistryUtils, cxControls, uIBANUtils, uStringsUtils; constructor TDatosBancariosEmpresaController.Create; begin @@ -44,38 +49,58 @@ begin inherited; end; +function TDatosBancariosEmpresaController.GenerarCodigoIBAN( + ADatosBancarios: IBizEmpresasDatosBancarios): string; +begin + Result := uIBANUtils.GenerarCodigoIBAN(ADatosBancarios.ENTIDAD, + ADatosBancarios.SUCURSAL, ADatosBancarios.DC, ADatosBancarios.CUENTA); +end; + +function TDatosBancariosEmpresaController.ValidarCodigoIBAN( + AIBAN: string): boolean; +begin + result := EsCodigoIBANValido(AIBAN) +end; + function TDatosBancariosEmpresaController.ValidarDatosBancarios( ADatosBancarios: IBizEmpresasDatosBancarios; AEmpresa : IBizEmpresa): Boolean; begin ADatosBancarios.DataTable.Edit; try - if not ADatosBancarios.IBANIsNull then + if not EsCadenaVacia(ADatosBancarios.IBAN) then begin ADatosBancarios.IBAN := StringReplace(ADatosBancarios.IBAN, ' ', '', [rfReplaceAll]); // Quitar espacios - if EsCodigoIBANValido(ADatosBancarios.IBAN) then - raise Exception.Create('Comprueba que el código IBAN indicado es correcto.'); + if not ValidarCodigoIBAN(ADatosBancarios.IBAN) then + raise Exception.Create(Format('Compruebe que el código IBAN de la cuenta %s es correcto.', [ADatosBancarios.NOMBRE])); + end + else begin + if not EsCadenaVacia(ADatosBancarios.ENTIDAD) and + not EsCadenaVacia(ADatosBancarios.SUCURSAL) and + not EsCadenaVacia(ADatosBancarios.DC) and + not EsCadenaVacia(ADatosBancarios.CUENTA) then + ADatosBancarios.IBAN := GenerarCodigoIBAN(ADatosBancarios); end; - if ADatosBancarios.SUFIJO_PRESENTADORIsNull then + if not EsCadenaVacia(ADatosBancarios.SUFIJO_PRESENTADOR) then ADatosBancarios.SUFIJO_PRESENTADOR := ADatosBancarios.SUFIJO_ACREEDOR; - if ADatosBancarios.ENTIDAD_PRESENTADORIsNull then + if not EsCadenaVacia(ADatosBancarios.ENTIDAD_PRESENTADOR) then ADatosBancarios.ENTIDAD_PRESENTADOR := ADatosBancarios.ENTIDAD; - if ADatosBancarios.SUCURSAL_PRESENTADORIsNull then + if not EsCadenaVacia(ADatosBancarios.SUCURSAL_PRESENTADOR) then ADatosBancarios.SUCURSAL_PRESENTADOR := ADatosBancarios.SUCURSAL; - if ADatosBancarios.NIF_CIF_PRESENTADORIsNull then + if not EsCadenaVacia(ADatosBancarios.NIF_CIF_PRESENTADOR) then ADatosBancarios.NIF_CIF_PRESENTADOR := AEmpresa.NIF_CIF; - if ADatosBancarios.NOMBRE_PRESENTADORIsNull then + if not EsCadenaVacia(ADatosBancarios.NOMBRE_PRESENTADOR) then ADatosBancarios.NOMBRE_PRESENTADOR := AEmpresa.NOMBRE; finally ADatosBancarios.DataTable.Post; - Result := True; end; + Result := True; end; procedure TDatosBancariosEmpresaController.Ver(ADatosBancarios : IBizEmpresasDatosBancarios); diff --git a/Source/ApplicationBase/Empresas/Views/uEditorDatosBancariosEmpresa.dfm b/Source/ApplicationBase/Empresas/Views/uEditorDatosBancariosEmpresa.dfm index 75c60fa..18d94be 100644 --- a/Source/ApplicationBase/Empresas/Views/uEditorDatosBancariosEmpresa.dfm +++ b/Source/ApplicationBase/Empresas/Views/uEditorDatosBancariosEmpresa.dfm @@ -9,6 +9,7 @@ object fEditorDatosBancariosEmpresa: TfEditorDatosBancariosEmpresa ParentFont = True OldCreateOrder = True Position = poOwnerFormCenter + OnCloseQuery = FormCloseQuery DesignSize = ( 449 469) @@ -117,6 +118,7 @@ object fEditorDatosBancariosEmpresa: TfEditorDatosBancariosEmpresa DataSource = dsDatosBancarios MaxLength = 4 TabOrder = 1 + OnExit = eCodEntidadExit end object eCodSucursal: TDBEdit Left = 109 @@ -127,6 +129,7 @@ object fEditorDatosBancariosEmpresa: TfEditorDatosBancariosEmpresa DataSource = dsDatosBancarios MaxLength = 4 TabOrder = 2 + OnExit = eCodSucursalExit end object eDC: TDBEdit Left = 109 @@ -137,6 +140,7 @@ object fEditorDatosBancariosEmpresa: TfEditorDatosBancariosEmpresa DataSource = dsDatosBancarios MaxLength = 2 TabOrder = 3 + OnExit = eDCExit end object eCuenta: TDBEdit Left = 109 @@ -146,6 +150,7 @@ object fEditorDatosBancariosEmpresa: TfEditorDatosBancariosEmpresa DataField = 'CUENTA' DataSource = dsDatosBancarios TabOrder = 4 + OnExit = eCuentaExit end object eSWIFT: TDBEdit Left = 109 @@ -154,17 +159,18 @@ object fEditorDatosBancariosEmpresa: TfEditorDatosBancariosEmpresa Height = 21 DataField = 'SWIFT' DataSource = dsDatosBancarios - TabOrder = 5 + TabOrder = 6 + end + object eIBAN: TDBEdit + Left = 109 + Top = 170 + Width = 204 + Height = 21 + DataField = 'IBAN' + DataSource = dsDatosBancarios + TabOrder = 5 + OnExit = eIBANExit end - end - object eIBAN: TDBEdit - Left = 117 - Top = 178 - Width = 204 - Height = 21 - DataField = 'IBAN' - DataSource = dsDatosBancarios - TabOrder = 3 end object GroupBox3: TGroupBox Left = 8 @@ -172,7 +178,7 @@ object fEditorDatosBancariosEmpresa: TfEditorDatosBancariosEmpresa Width = 433 Height = 215 Caption = 'Configuraci'#243'n de norma SEPA' - TabOrder = 4 + TabOrder = 3 object Label10: TLabel Left = 12 Top = 28 diff --git a/Source/ApplicationBase/Empresas/Views/uEditorDatosBancariosEmpresa.pas b/Source/ApplicationBase/Empresas/Views/uEditorDatosBancariosEmpresa.pas index 35e006f..9654e23 100644 --- a/Source/ApplicationBase/Empresas/Views/uEditorDatosBancariosEmpresa.pas +++ b/Source/ApplicationBase/Empresas/Views/uEditorDatosBancariosEmpresa.pas @@ -45,6 +45,12 @@ type eCodEntidadPresentador: TDBEdit; Label18: TLabel; eCodSucursalPresentador: TDBEdit; + procedure eCodEntidadExit(Sender: TObject); + procedure eCodSucursalExit(Sender: TObject); + procedure eDCExit(Sender: TObject); + procedure eCuentaExit(Sender: TObject); + procedure eIBANExit(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); protected FController : IDatosBancariosEmpresaController; FDatosBancarios: IBizEmpresasDatosBancarios; @@ -54,6 +60,8 @@ type function GetDatosBancarios: IBizEmpresasDatosBancarios; procedure SetDatosBancarios(const Value: IBizEmpresasDatosBancarios); + + procedure CalcularCodigoIBAN(); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -65,12 +73,24 @@ type implementation uses - Variants; + Variants, uStringsUtils; {$R *.dfm} { TfEditorDireccion } +procedure TfEditorDatosBancariosEmpresa.CalcularCodigoIBAN; +begin + if not EsCadenaVacia(FDatosBancarios.ENTIDAD) and + not EsCadenaVacia(FDatosBancarios.SUCURSAL) and + not EsCadenaVacia(FDatosBancarios.DC) and + not EsCadenaVacia(FDatosBancarios.CUENTA) then + begin + FDatosBancarios.Edit; + FDatosBancarios.IBAN := FController.GenerarCodigoIBAN(FDatosBancarios); + end; +end; + constructor TfEditorDatosBancariosEmpresa.Create(AOwner: TComponent); begin inherited; @@ -83,6 +103,43 @@ begin inherited; end; +procedure TfEditorDatosBancariosEmpresa.eCodEntidadExit(Sender: TObject); +begin + CalcularCodigoIBAN(); +end; + +procedure TfEditorDatosBancariosEmpresa.eCodSucursalExit(Sender: TObject); +begin + CalcularCodigoIBAN(); +end; + +procedure TfEditorDatosBancariosEmpresa.eCuentaExit(Sender: TObject); +begin + CalcularCodigoIBAN(); +end; + +procedure TfEditorDatosBancariosEmpresa.eDCExit(Sender: TObject); +begin + CalcularCodigoIBAN(); +end; + +procedure TfEditorDatosBancariosEmpresa.eIBANExit(Sender: TObject); +begin + if not EsCadenaVacia(eIBAN.Text) and not FController.ValidarCodigoIBAN(eIBAN.Text) then + begin + raise Exception.Create('Compruebe que el código IBAN indicado es correcto.'); + end; +end; + +procedure TfEditorDatosBancariosEmpresa.FormCloseQuery(Sender: TObject; + var CanClose: Boolean); +begin + if not EsCadenaVacia(eIBAN.Text) and not FController.ValidarCodigoIBAN(eIBAN.Text) then + begin + raise Exception.Create('Compruebe que el código IBAN indicado es correcto.'); + end; +end; + function TfEditorDatosBancariosEmpresa.GetController: IDatosBancariosEmpresaController; begin Result := FController; diff --git a/Source/Base/Base.RES b/Source/Base/Base.RES index 8b251f3..1641339 100644 Binary files a/Source/Base/Base.RES and b/Source/Base/Base.RES differ diff --git a/Source/Base/Base.dproj b/Source/Base/Base.dproj index 5157b67..970fa2b 100644 --- a/Source/Base/Base.dproj +++ b/Source/Base/Base.dproj @@ -53,30 +53,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - Microsoft Office 2000 Sample Automation Server Wrapper Components Microsoft Office XP Sample Automation Server Wrapper Components Base.dpk @@ -95,6 +71,58 @@ TDataModule + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fConfigurarConexion
TForm @@ -118,59 +146,14 @@
dmBase
TDataModule
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -194,13 +177,6 @@ - - - - - - -