git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES2/trunk@205 b2cfbe5a-eba1-4a0c-8b32-7feea0a119f2
126 lines
4.2 KiB
ObjectPascal
126 lines
4.2 KiB
ObjectPascal
unit uDatosBancariosEmpresaController;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Forms, Classes, Controls, Contnrs, SysUtils, uDADataTable,
|
||
uBizEmpresas, uBizEmpresasDatosBancarios, uIDataModuleEmpresas,
|
||
uControllerBase;
|
||
|
||
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;
|
||
|
||
TDatosBancariosEmpresaController = class(TControllerBase, IDatosBancariosEmpresaController)
|
||
private
|
||
FDataModule : IDataModuleEmpresas;
|
||
protected
|
||
public
|
||
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;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{ TDatosBancariosEmpresaController }
|
||
|
||
uses
|
||
uDataModuleEmpresas, schEmpresasClient_Intf, uIEditorDatosBancarioEmpresa,
|
||
uEditorRegistryUtils, cxControls, uIBANUtils, uStringsUtils;
|
||
|
||
constructor TDatosBancariosEmpresaController.Create;
|
||
begin
|
||
inherited;
|
||
// FDataModule := TDataModuleEmpresas.Create(Nil);
|
||
end;
|
||
|
||
destructor TDatosBancariosEmpresaController.Destroy;
|
||
begin
|
||
FDataModule := Nil;
|
||
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 EsCadenaVacia(ADatosBancarios.IBAN) then
|
||
begin
|
||
ADatosBancarios.IBAN := StringReplace(ADatosBancarios.IBAN, ' ', '', [rfReplaceAll]); // Quitar espacios
|
||
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 not EsCadenaVacia(ADatosBancarios.SUFIJO_PRESENTADOR) then
|
||
ADatosBancarios.SUFIJO_PRESENTADOR := ADatosBancarios.SUFIJO_ACREEDOR;
|
||
|
||
if not EsCadenaVacia(ADatosBancarios.ENTIDAD_PRESENTADOR) then
|
||
ADatosBancarios.ENTIDAD_PRESENTADOR := ADatosBancarios.ENTIDAD;
|
||
|
||
if not EsCadenaVacia(ADatosBancarios.SUCURSAL_PRESENTADOR) then
|
||
ADatosBancarios.SUCURSAL_PRESENTADOR := ADatosBancarios.SUCURSAL;
|
||
|
||
if not EsCadenaVacia(ADatosBancarios.NIF_CIF_PRESENTADOR) then
|
||
ADatosBancarios.NIF_CIF_PRESENTADOR := AEmpresa.NIF_CIF;
|
||
|
||
if not EsCadenaVacia(ADatosBancarios.NOMBRE_PRESENTADOR) then
|
||
ADatosBancarios.NOMBRE_PRESENTADOR := AEmpresa.NOMBRE;
|
||
|
||
finally
|
||
ADatosBancarios.DataTable.Post;
|
||
end;
|
||
Result := True;
|
||
end;
|
||
|
||
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.
|