147 lines
4.8 KiB
ObjectPascal
147 lines
4.8 KiB
ObjectPascal
|
|
{
|
|||
|
|
===============================================================================
|
|||
|
|
Copyright (<EFBFBD>) 2007. Rodax Software.
|
|||
|
|
===============================================================================
|
|||
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|||
|
|
copyright. Este fichero s<EFBFBD>lo podr<EFBFBD> ser copiado, distribuido y utilizado,
|
|||
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|||
|
|
acuerdo con los t<EFBFBD>rminos y condiciones establecidas en el acuerdo/contrato
|
|||
|
|
bajo el que se suministra.
|
|||
|
|
-----------------------------------------------------------------------------
|
|||
|
|
Web: www.rodax-software.com
|
|||
|
|
===============================================================================
|
|||
|
|
Fecha primera versi<EFBFBD>n:
|
|||
|
|
Versi<EFBFBD>n actual: 1.0.0
|
|||
|
|
Fecha versi<EFBFBD>n actual:
|
|||
|
|
===============================================================================
|
|||
|
|
Modificaciones:
|
|||
|
|
|
|||
|
|
Fecha Comentarios
|
|||
|
|
---------------------------------------------------------------------------
|
|||
|
|
===============================================================================
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
unit uPagosClienteController;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Classes, SysUtils, uDADataTable, uControllerBase, uIDataModuleRecibosCliente,
|
|||
|
|
uBizPagosCliente;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IPagosClienteController = interface(ISujeto)
|
|||
|
|
['{1864471E-74FA-4E96-BA8D-21357DA38B0F}']
|
|||
|
|
function Anadir(APagosCliente: IBizPagosCliente; Const Fecha: String = ''): Boolean;
|
|||
|
|
procedure Modificar(APagosCliente: IBizPagosCliente; Const Fecha: String);
|
|||
|
|
function Eliminar(APagoCliente : IBizPagosCliente): Boolean;
|
|||
|
|
function EliminarTodo(APagossCliente : IBizPagosCliente): Boolean;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TPagosClienteController = class(TSujeto, IPagosClienteController)
|
|||
|
|
protected
|
|||
|
|
FDataModule : IDataModuleRecibosCliente;
|
|||
|
|
|
|||
|
|
procedure AsignarDataModule;
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
constructor Create; virtual;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
function Anadir(APagosCliente: IBizPagosCliente; Const Fecha: String = ''): Boolean;
|
|||
|
|
procedure Modificar(APagosCliente: IBizPagosCliente; Const Fecha: String);
|
|||
|
|
function Eliminar(APagoCliente : IBizPagosCliente): Boolean;
|
|||
|
|
function EliminarTodo(APagosCliente : IBizPagosCliente): Boolean;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
cxControls, DB, uEditorRegistryUtils,Dialogs,
|
|||
|
|
uDAInterfaces, uDataTableUtils, uDataModuleUsuarios,
|
|||
|
|
uDateUtils, uROTypes, DateUtils, Controls, Windows, Variants,
|
|||
|
|
schRecibosClienteClient_Intf, uDataModuleRecibosCliente;
|
|||
|
|
|
|||
|
|
{ TPagosClienteController }
|
|||
|
|
|
|||
|
|
function TPagosClienteController.Anadir(APagosCliente: IBizPagosCliente; Const Fecha: String = ''): Boolean;
|
|||
|
|
{ Si el pago introducido es un pago y no una devoluci<EFBFBD>n devolvemos true en caso de ser
|
|||
|
|
una devoluci<EFBFBD>n devolvemos false}
|
|||
|
|
begin
|
|||
|
|
APagosCliente.Append;
|
|||
|
|
if Length(Fecha) = 0 then
|
|||
|
|
APagosCliente.FECHA_PAGO := Date
|
|||
|
|
else
|
|||
|
|
APagosCliente.FECHA_PAGO := StrToDate(Fecha);
|
|||
|
|
|
|||
|
|
if (APagosCliente.DataTable.RecordCount = 0)
|
|||
|
|
or ((APagosCliente.DataTable.RecordCount mod 2) = 0) then
|
|||
|
|
APagosCliente.TIPO := CTE_PAGO
|
|||
|
|
else
|
|||
|
|
APagosCliente.TIPO := CTE_DEVOLUCION;
|
|||
|
|
|
|||
|
|
Result := (APagosCliente.TIPO = CTE_PAGO);
|
|||
|
|
APagosCliente.Post;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TPagosClienteController.AsignarDataModule;
|
|||
|
|
begin
|
|||
|
|
FDataModule := TDataModuleRecibosCliente.Create(Nil);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TPagosClienteController.Create;
|
|||
|
|
begin
|
|||
|
|
AsignarDataModule;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TPagosClienteController.Destroy;
|
|||
|
|
begin
|
|||
|
|
FDataModule := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TPagosClienteController.Eliminar(APagoCliente: IBizPagosCliente): Boolean;
|
|||
|
|
{ En el caso de eliminar un cobro del recibo devuelve true, mientras que si lo que
|
|||
|
|
se borra es una devoluci<EFBFBD>n devuelve false}
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
|
|||
|
|
if not Assigned(APagoCliente) then
|
|||
|
|
raise Exception.Create ('IBizPagosCliente no asignado');
|
|||
|
|
|
|||
|
|
ShowHourglassCursor;
|
|||
|
|
try
|
|||
|
|
if (APagoCliente.State in dsEditModes) then
|
|||
|
|
APagoCliente.Cancel;
|
|||
|
|
|
|||
|
|
APagoCliente.Last;
|
|||
|
|
Result := (APagoCliente.TIPO = CTE_PAGO);
|
|||
|
|
APagoCliente.Delete;
|
|||
|
|
//Todo lo haremos en memoria ya que los pagos no tienen entidad propia
|
|||
|
|
//APagosCliente.DataTable.ApplyUpdates;
|
|||
|
|
finally
|
|||
|
|
HideHourglassCursor;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TPagosClienteController.EliminarTodo(APagosCliente: IBizPagosCliente): Boolean;
|
|||
|
|
begin
|
|||
|
|
if Assigned(APagosCliente) then
|
|||
|
|
begin
|
|||
|
|
if not APagosCliente.DataTable.Active then
|
|||
|
|
APagosCliente.DataTable.Active := True;
|
|||
|
|
APagosCliente.DataTable.ClearRows;
|
|||
|
|
//Todo lo haremos en memoria ya que los pagos no tienen entidad propia
|
|||
|
|
//APagosCliente.DataTable.ApplyUpdates;
|
|||
|
|
Result := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TPagosClienteController.Modificar(APagosCliente: IBizPagosCliente; const Fecha: String);
|
|||
|
|
begin
|
|||
|
|
APagosCliente.DataTable.Edit;
|
|||
|
|
APagosCliente.FECHA_PAGO := StrToDate(Fecha);
|
|||
|
|
APagosCliente.DataTable.Post;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|