2010-08-11 10:53:06 +00:00
|
|
|
|
unit uDatosBancariosEmpresaController;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Forms, Classes, Controls, Contnrs, SysUtils, uDADataTable,
|
|
|
|
|
|
uBizEmpresas, uBizEmpresasDatosBancarios, uIDataModuleEmpresas,
|
|
|
|
|
|
uControllerBase;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
IDatosBancariosEmpresaController = interface(IControllerBase)
|
|
|
|
|
|
['{E9B0313E-7B16-420A-B47E-20E42E96BAC6}']
|
2013-12-13 13:07:39 +00:00
|
|
|
|
function GenerarCodigoIBAN (ADatosBancarios : IBizEmpresasDatosBancarios) : string;
|
|
|
|
|
|
function ValidarCodigoIBAN (AIBAN : string) : boolean;
|
|
|
|
|
|
function ValidarDatosBancarios(ADatosBancarios : IBizEmpresasDatosBancarios; AEmpresa : IBizEmpresa): Boolean;
|
2010-08-11 10:53:06 +00:00
|
|
|
|
procedure Ver(ADatosBancarios : IBizEmpresasDatosBancarios);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TDatosBancariosEmpresaController = class(TControllerBase, IDatosBancariosEmpresaController)
|
|
|
|
|
|
private
|
|
|
|
|
|
FDataModule : IDataModuleEmpresas;
|
2013-12-13 09:42:56 +00:00
|
|
|
|
protected
|
2010-08-11 10:53:06 +00:00
|
|
|
|
public
|
2013-12-13 13:07:39 +00:00
|
|
|
|
function GenerarCodigoIBAN (ADatosBancarios : IBizEmpresasDatosBancarios) : string;
|
|
|
|
|
|
function ValidarCodigoIBAN (AIBAN : string) : boolean;
|
|
|
|
|
|
function ValidarDatosBancarios(ADatosBancarios : IBizEmpresasDatosBancarios; AEmpresa : IBizEmpresa): Boolean; virtual;
|
2010-08-11 10:53:06 +00:00
|
|
|
|
procedure Ver(ADatosBancarios : IBizEmpresasDatosBancarios);
|
|
|
|
|
|
constructor Create; override;
|
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
{ TDatosBancariosEmpresaController }
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
uDataModuleEmpresas, schEmpresasClient_Intf, uIEditorDatosBancarioEmpresa,
|
2013-12-13 13:07:39 +00:00
|
|
|
|
uEditorRegistryUtils, cxControls, uIBANUtils, uStringsUtils;
|
2010-08-11 10:53:06 +00:00
|
|
|
|
|
|
|
|
|
|
constructor TDatosBancariosEmpresaController.Create;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
// FDataModule := TDataModuleEmpresas.Create(Nil);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TDatosBancariosEmpresaController.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FDataModule := Nil;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2013-12-13 13:07:39 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
2013-12-13 09:42:56 +00:00
|
|
|
|
function TDatosBancariosEmpresaController.ValidarDatosBancarios(
|
|
|
|
|
|
ADatosBancarios: IBizEmpresasDatosBancarios; AEmpresa : IBizEmpresa): Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
ADatosBancarios.DataTable.Edit;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
2013-12-13 13:07:39 +00:00
|
|
|
|
if not EsCadenaVacia(ADatosBancarios.IBAN) then
|
2013-12-13 11:37:18 +00:00
|
|
|
|
begin
|
2013-12-13 09:42:56 +00:00
|
|
|
|
ADatosBancarios.IBAN := StringReplace(ADatosBancarios.IBAN, ' ', '', [rfReplaceAll]); // Quitar espacios
|
2013-12-13 13:07:39 +00:00
|
|
|
|
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);
|
2013-12-13 11:37:18 +00:00
|
|
|
|
end;
|
2013-12-13 09:42:56 +00:00
|
|
|
|
|
2013-12-13 13:07:39 +00:00
|
|
|
|
if not EsCadenaVacia(ADatosBancarios.SUFIJO_PRESENTADOR) then
|
2013-12-13 09:42:56 +00:00
|
|
|
|
ADatosBancarios.SUFIJO_PRESENTADOR := ADatosBancarios.SUFIJO_ACREEDOR;
|
|
|
|
|
|
|
2013-12-13 13:07:39 +00:00
|
|
|
|
if not EsCadenaVacia(ADatosBancarios.ENTIDAD_PRESENTADOR) then
|
2013-12-13 09:42:56 +00:00
|
|
|
|
ADatosBancarios.ENTIDAD_PRESENTADOR := ADatosBancarios.ENTIDAD;
|
|
|
|
|
|
|
2013-12-13 13:07:39 +00:00
|
|
|
|
if not EsCadenaVacia(ADatosBancarios.SUCURSAL_PRESENTADOR) then
|
2013-12-13 09:42:56 +00:00
|
|
|
|
ADatosBancarios.SUCURSAL_PRESENTADOR := ADatosBancarios.SUCURSAL;
|
|
|
|
|
|
|
2013-12-13 13:07:39 +00:00
|
|
|
|
if not EsCadenaVacia(ADatosBancarios.NIF_CIF_PRESENTADOR) then
|
2013-12-13 09:42:56 +00:00
|
|
|
|
ADatosBancarios.NIF_CIF_PRESENTADOR := AEmpresa.NIF_CIF;
|
|
|
|
|
|
|
2013-12-13 13:07:39 +00:00
|
|
|
|
if not EsCadenaVacia(ADatosBancarios.NOMBRE_PRESENTADOR) then
|
2013-12-13 09:42:56 +00:00
|
|
|
|
ADatosBancarios.NOMBRE_PRESENTADOR := AEmpresa.NOMBRE;
|
|
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
ADatosBancarios.DataTable.Post;
|
|
|
|
|
|
end;
|
2013-12-13 13:07:39 +00:00
|
|
|
|
Result := True;
|
2013-12-13 09:42:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2010-08-11 10:53:06 +00:00
|
|
|
|
procedure TDatosBancariosEmpresaController.Ver(ADatosBancarios : IBizEmpresasDatosBancarios);
|
|
|
|
|
|
var
|
|
|
|
|
|
AEditor : IEditorDatosBancariosEmpresa;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AEditor := NIL;
|
|
|
|
|
|
CreateEditor('EditorDatosBancariosEmpresa', IEditorDatosBancariosEmpresa, AEditor);
|
|
|
|
|
|
if Assigned(AEditor) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
try
|
|
|
|
|
|
AEditor.DatosBancarios := ADatosBancarios;
|
|
|
|
|
|
AEditor.Controller := Self;
|
|
|
|
|
|
AEditor.ShowModal;
|
|
|
|
|
|
finally
|
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
|
AEditor := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|