unit uBizEpigrafes;

interface

uses
  uDAInterfaces, uDADataTable, uDBSelectionListUtils, schContabilidadClient_Intf;

const
  BIZ_CLIENT_Epigrafe = 'Client.Epigrafe';

type
  IBizEpigrafe = interface(IEpigrafes)
    ['{F79E3238-1E0D-4FB6-9AF7-E5703619B067}']
    function EsNuevo : Boolean;
  end;

  TBizEpigrafe = class(TEpigrafesDataTableRules, IBizEpigrafe, ISeleccionable)
  protected
    FSeleccionableInterface : ISeleccionable;
    procedure OnNewRecord(Sender: TDADataTable); override;
  public
    property SeleccionableInterface : ISeleccionable read FSeleccionableInterface
        write FSeleccionableInterface implements ISeleccionable;

    constructor Create(aDataTable: TDADataTable); override;
    destructor Destroy; override;

    procedure IniciarValoresEpigrafeNueva;
    function EsNuevo : Boolean;
  end;

implementation

{ TBizEpigrafe }

uses
  SysUtils, uDataTableUtils, uFactuGES_App;

constructor TBizEpigrafe.Create(aDataTable: TDADataTable);
begin
  inherited;
  FSeleccionableInterface := TSeleccionable.Create(aDataTable);
end;

destructor TBizEpigrafe.Destroy;
begin
  FSeleccionableInterface := NIL;
  inherited;
end;

function TBizEpigrafe.EsNuevo: Boolean;
begin
  Result := (ID < 0);
end;

procedure TBizEpigrafe.IniciarValoresEpigrafeNueva;
begin
  ID_EJERCICIO := AppFactuGES.EjercicioActivo.ID;
  ESTADO := AppFactuGES.EjercicioActivo.ESTADO;  
end;

procedure TBizEpigrafe.OnNewRecord(Sender: TDADataTable);
begin
  inherited;
  IniciarValoresEpigrafeNueva;
end;

initialization
  RegisterDataTableRules(BIZ_CLIENT_Epigrafe, TBizEpigrafe);

finalization

end.

