unit uBizBalances;

interface

uses
  uDAInterfaces, uDADataTable, uDBSelectionListUtils, schContabilidadClient_Intf;

const
  BIZ_CLIENT_Balance = 'Client.Balance';

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

  TBizBalance = class(TBalancesDataTableRules, IBizBalance, 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 IniciarValoresBalanceNueva;
    function EsNuevo : Boolean;
  end;

implementation

{ TBizBalance }

uses
  SysUtils, uDataTableUtils;

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

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

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

procedure TBizBalance.IniciarValoresBalanceNueva;
begin
  NATURALEZA := 'DEBE';
end;

procedure TBizBalance.OnNewRecord(Sender: TDADataTable);
begin
  inherited;
  IniciarValoresBalanceNueva;
end;

initialization
  RegisterDataTableRules(BIZ_CLIENT_Balance, TBizBalance);

finalization

end.

