git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES2/trunk@25 40301925-124e-1c4e-b97d-170ad7a8785b
436 lines
14 KiB
ObjectPascal
436 lines
14 KiB
ObjectPascal
{
|
|
===============================================================================
|
|
Copyright (©) 2007. Rodax Software.
|
|
===============================================================================
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|
copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|
acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
|
|
bajo el que se suministra.
|
|
-----------------------------------------------------------------------------
|
|
Web: www.rodax-software.com
|
|
===============================================================================
|
|
Fecha primera versión:
|
|
Versión actual: 1.0.0
|
|
Fecha versión actual:
|
|
===============================================================================
|
|
Modificaciones:
|
|
|
|
Fecha Comentarios
|
|
---------------------------------------------------------------------------
|
|
===============================================================================
|
|
}
|
|
|
|
unit uEditorRecibosCliente;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, Menus, DB, uDADataTable, JvAppStorage,
|
|
JvAppRegistryStorage, JvComponent, JvFormPlacement, ImgList,
|
|
PngImageList, StdActns, ActnList, ComCtrls, TB2ExtItems, TBXExtItems,
|
|
TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls, JvExControls,
|
|
JvNavigationPane, uViewGrid, pngimage, JvComponentBase,
|
|
JvExComCtrls, JvStatusBar, uViewBase, uViewBarraSeleccion, uViewGridBase,
|
|
uEditorGridBase, uCustomView,
|
|
|
|
uBizRecibosCliente, uIEditorRecibosCliente, uRecibosClienteController,
|
|
uViewRecibosCliente, JSDialog, uDAInterfaces;
|
|
|
|
type
|
|
|
|
TfEditorRecibosCliente = class(TfEditorGridBase, IEditorRecibosCliente)
|
|
frViewRecibosCliente1: TfrViewRecibosCliente;
|
|
JsPrevisualizarDialog: TJSDialog;
|
|
JsImprimirDialog: TJSDialog;
|
|
JSInformesDialog: TJSDialog;
|
|
actInformes: TAction;
|
|
TBXItem38: TTBXItem;
|
|
actCambioSituacion: TAction;
|
|
TBXSeparatorItem17: TTBXSeparatorItem;
|
|
TBXItem39: TTBXItem;
|
|
procedure FormShow(Sender: TObject);
|
|
procedure actEliminarUpdate(Sender: TObject);
|
|
procedure actInformesExecute(Sender: TObject);
|
|
procedure OnListaAnosChange(Sender: TObject; const Text: string);
|
|
procedure actCambioSituacionExecute(Sender: TObject);
|
|
|
|
private
|
|
FRecibosCliente: IBizRecibosCliente;
|
|
FController : IRecibosClienteController;
|
|
protected
|
|
function GetRecibosCliente: IBizRecibosCliente;
|
|
procedure SetRecibosCliente(const Value: IBizRecibosCliente);
|
|
function GetController : IRecibosClienteController;
|
|
procedure SetController (const Value : IRecibosClienteController);
|
|
|
|
procedure NuevoInterno; override;
|
|
procedure EliminarInterno; override;
|
|
procedure ModificarInterno; override;
|
|
procedure DuplicarInterno; override;
|
|
procedure ImprimirInterno; override;
|
|
procedure PrevisualizarInterno; override;
|
|
procedure RefrescarInterno; override;
|
|
|
|
public
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|
property RecibosCliente: IBizRecibosCliente read GetRecibosCliente write SetRecibosCliente;
|
|
property Controller : IRecibosClienteController read GetController write SetController;
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
uDataModuleRecibosCliente, uDataModuleUsuarios, uFactuGES_App, uEditorFechaPago,
|
|
uGridUtils, uDBSelectionListUtils, uGestorInformesController;
|
|
|
|
{$R *.dfm}
|
|
|
|
{
|
|
*************************** TfEditorRecibosCliente ***************************
|
|
}
|
|
procedure TfEditorRecibosCliente.actCambioSituacionExecute(Sender: TObject);
|
|
var
|
|
AFechaPago: String;
|
|
AIgnorarContabilidad: Integer;
|
|
AIdSubCuenta: Integer;
|
|
ASubCuenta: String;
|
|
ARecibos: IBizRecibosCliente;
|
|
AllItems: Boolean;
|
|
|
|
begin
|
|
inherited;
|
|
|
|
ARecibos := Nil;
|
|
AllItems := False;
|
|
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|
|
|
if AllItems then
|
|
begin
|
|
if (Application.MessageBox('¿Desea cambiar a pagados los recibos de cliente seleccionados, en caso de tener recibos ya pagados en la selección, estos no serán modificados?', 'Atención', MB_YESNO) = IDYES) then
|
|
begin
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (RecibosCliente as ISeleccionable).SelectedRecords);
|
|
ARecibos := (Controller as IRecibosClienteController).ExtraerSeleccionados(RecibosCliente) as IBizRecibosCliente;
|
|
end
|
|
else
|
|
exit;
|
|
end
|
|
else begin
|
|
ARecibos := Controller.Buscar(RecibosCliente.ID);
|
|
ARecibos.DataTable.active := True;
|
|
end;
|
|
|
|
with TfEditorFechaPago.Create(Nil) do
|
|
begin
|
|
if (ShowModal = mrOk) then
|
|
begin
|
|
AFechaPago := DateToStr(FechaPago);
|
|
AIgnorarContabilidad := IgnorarContabilidad;
|
|
AIdSubCuenta := IdSubcuenta;
|
|
ASubCuenta := frViewListaSubcuentas1.cbSubCuentas.Text;
|
|
Release;
|
|
end
|
|
else
|
|
begin
|
|
//Operación cancelada
|
|
Release;
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
if Assigned(ARecibos) then
|
|
begin
|
|
ViewGrid._Grid.BeginUpdate;
|
|
ViewGrid._Grid.EndUpdate;
|
|
FController.AnadirPagos(ARecibos, AFechaPago, AIgnorarContabilidad, AIdSubCuenta, ASubCuenta);
|
|
FController.Guardar(ARecibos);
|
|
actRefrescar.Execute;
|
|
ViewGrid._Grid.EndUpdate;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.actEliminarUpdate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
if (Sender as TAction).Enabled then
|
|
(Sender as TAction).Enabled := (FRecibosCliente.SITUACION = CTE_PENDIENTE) AND (FRecibosCliente.ID_FACTURA < 1);
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.actInformesExecute(Sender: TObject);
|
|
var
|
|
Respuesta : Integer;
|
|
AGestorInformesController : IGestorInformesController;
|
|
|
|
begin
|
|
AGestorInformesController := TGestorInformesController.Create;
|
|
try
|
|
|
|
Respuesta := JsInformesDialog.Execute;
|
|
|
|
if Respuesta <> IDCANCEL then
|
|
begin
|
|
case JsInformesDialog.CustomButtonResult of
|
|
100 : begin // Listado de recibos pendientes
|
|
AGestorInformesController.VerInformeListadoRecibosCliPendientes;
|
|
end;
|
|
200 : begin // Listado de recibos de cliente
|
|
AGestorInformesController.VerInformeListadoRecibosCliente;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
finally
|
|
AGestorInformesController := NIL;
|
|
end;
|
|
end;
|
|
|
|
constructor TfEditorRecibosCliente.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
FController := TRecibosClienteController.Create;
|
|
ViewGrid := frViewRecibosCliente1; // CreateView(TfrViewRecibosCliente) as IViewRecibosCliente;
|
|
end;
|
|
|
|
destructor TfEditorRecibosCliente.Destroy;
|
|
begin
|
|
FRecibosCliente := NIL;
|
|
FController := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.DuplicarInterno;
|
|
begin
|
|
// No se pueden duplicar recibos
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.EliminarInterno;
|
|
var
|
|
ARecibos: IBizRecibosCliente;
|
|
AllItems: Boolean;
|
|
begin
|
|
ARecibos := Nil;
|
|
AllItems := False;
|
|
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|
|
|
if AllItems then
|
|
begin
|
|
if (Application.MessageBox('¿Desea borrar los recibos de cliente seleccionados?', 'Atención', MB_YESNO) = IDYES) then
|
|
begin
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (RecibosCliente as ISeleccionable).SelectedRecords);
|
|
ARecibos := (Controller as IRecibosClienteController).ExtraerSeleccionados(RecibosCliente) as IBizRecibosCliente;
|
|
end
|
|
end
|
|
else begin
|
|
if (Application.MessageBox('¿Desea borrar el recibo de cliente seleccionado?', 'Atención', MB_YESNO) = IDYES) then
|
|
ARecibos := RecibosCliente;
|
|
end;
|
|
|
|
if Assigned(ARecibos) then
|
|
begin
|
|
FController.Eliminar(ARecibos, AllItems);
|
|
if AllItems then
|
|
begin
|
|
if (ARecibos.DataTable.RecordCount > 0) then
|
|
begin
|
|
with ARecibos.DataTable do
|
|
begin
|
|
First;
|
|
while not EOF do
|
|
begin
|
|
// JsListaPresupuestosNoEliminados.Content.Add('Ref. Presupuesto: ' + APresupuestos.REFERENCIA + ' ' + APresupuestos.NOMBRE);
|
|
Next;
|
|
end;
|
|
end;
|
|
// JsListaRecibosNoEliminados.Execute;
|
|
end;
|
|
actRefrescar.Execute;
|
|
end;
|
|
end;
|
|
|
|
ViewGrid.GotoFirst;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.FormShow(Sender: TObject);
|
|
begin
|
|
cbxListaAnos.OnChange := OnListaAnosChange; //OJO SIEMPRE ANTES DEL INHERITED
|
|
|
|
inherited;
|
|
|
|
if not Assigned(ViewGrid) then
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|
|
|
if not Assigned(FRecibosCliente) then
|
|
raise Exception.Create('No hay ningún objeto asignado');
|
|
|
|
FRecibosCliente.DataTable.Active := True;
|
|
ViewGrid.GotoFirst;
|
|
end;
|
|
|
|
function TfEditorRecibosCliente.GetController: IRecibosClienteController;
|
|
begin
|
|
Result := FController;
|
|
end;
|
|
|
|
function TfEditorRecibosCliente.GetRecibosCliente: IBizRecibosCliente;
|
|
begin
|
|
Result := FRecibosCliente;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.ImprimirInterno;
|
|
var
|
|
Respuesta : Integer;
|
|
ARecibosCliente: IBizRecibosCliente;
|
|
AllItems: Boolean;
|
|
begin
|
|
ARecibosCliente := Nil;
|
|
AllItems := False;
|
|
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|
|
|
//Si esta agrupado solo podré imprimir la lista de elementos visibles
|
|
if not ViewGrid.esSeleccionCeldaDatos then
|
|
inherited
|
|
else
|
|
begin
|
|
Respuesta := JsPrevisualizarDialog.Execute;
|
|
if Respuesta <> IDCANCEL then
|
|
begin
|
|
case JsPrevisualizarDialog.CustomButtonResult of
|
|
200 : begin // Lista de elementos visibles
|
|
inherited;
|
|
end;
|
|
100 : begin // Elemento Seleccionado
|
|
if AllItems then
|
|
begin
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (RecibosCliente as ISeleccionable).SelectedRecords);
|
|
ARecibosCliente := (Controller as IRecibosClienteController).ExtraerSeleccionados(RecibosCliente) as IBizRecibosCliente;
|
|
end
|
|
else
|
|
ARecibosCliente := RecibosCliente;
|
|
|
|
if Assigned(ARecibosCliente) then
|
|
FController.Preview(ARecibosCliente, AllItems);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.ModificarInterno;
|
|
begin
|
|
inherited;
|
|
FController.Ver(FRecibosCliente);
|
|
RefrescarInterno;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.NuevoInterno;
|
|
begin
|
|
inherited;
|
|
//Se pueden añadir recibos nuevos sin tener factura asociada, ya que acana emite recibos independientes a las facturas
|
|
//por ser particulares en lugar de empresas el cliente final.
|
|
FController.Anadir(FRecibosCliente);
|
|
FController.Ver(FRecibosCliente);
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.OnListaAnosChange(Sender: TObject; const Text: string);
|
|
begin
|
|
Controller.FiltrarAno(RecibosCliente, DynWhereDataTable, Text);
|
|
if RecibosCliente.DataTable.Active then
|
|
RefrescarInterno;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.PonerTitulos(const ATitulo: string);
|
|
var
|
|
FTitulo : String;
|
|
begin
|
|
FTitulo := 'Lista de recibos de cliente - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
inherited PonerTitulos(FTitulo);
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.PrevisualizarInterno;
|
|
var
|
|
Respuesta : Integer;
|
|
ARecibosCliente: IBizRecibosCliente;
|
|
AllItems: Boolean;
|
|
begin
|
|
ARecibosCliente := Nil;
|
|
AllItems := False;
|
|
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|
|
|
//Si esta agrupado solo podré imprimir la lista de elementos visibles
|
|
if not ViewGrid.esSeleccionCeldaDatos then
|
|
inherited
|
|
else
|
|
begin
|
|
Respuesta := JsPrevisualizarDialog.Execute;
|
|
if Respuesta <> IDCANCEL then
|
|
begin
|
|
case JsPrevisualizarDialog.CustomButtonResult of
|
|
200 : begin // Lista de elementos visibles
|
|
inherited;
|
|
end;
|
|
100 : begin // Elemento Seleccionado
|
|
if AllItems then
|
|
begin
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (RecibosCliente as ISeleccionable).SelectedRecords);
|
|
ARecibosCliente := (Controller as IRecibosClienteController).ExtraerSeleccionados(RecibosCliente) as IBizRecibosCliente;
|
|
end
|
|
else
|
|
ARecibosCliente := RecibosCliente;
|
|
|
|
if Assigned(ARecibosCliente) then
|
|
FController.Preview(ARecibosCliente, AllItems);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.RefrescarInterno;
|
|
begin
|
|
//Volvemos a cargar los años de los recibos
|
|
if Assigned(FController) then
|
|
ListaAnos := FController.DarListaAnosRecibos;
|
|
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.SetController(const Value: IRecibosClienteController);
|
|
begin
|
|
FController := Value;
|
|
|
|
if Assigned(FController) then
|
|
ListaAnos := FController.DarListaAnosRecibos;
|
|
end;
|
|
|
|
procedure TfEditorRecibosCliente.SetRecibosCliente(const Value: IBizRecibosCliente);
|
|
begin
|
|
FRecibosCliente := Value;
|
|
|
|
if Assigned(FRecibosCliente) then
|
|
begin
|
|
//Se guarda el where de la sentencia origen, por si el editor tiene filtros que
|
|
//afecten a este where y en un futuro se desea volver al where origen (filtro de año))
|
|
DynWhereDataTable := FRecibosCliente.DataTable.DynamicWhere.Xml;
|
|
|
|
dsDataTable.DataTable := FRecibosCliente.DataTable;
|
|
if Assigned(ViewGrid) then
|
|
(ViewGrid as IViewRecibosCliente).Recibos := FRecibosCliente;
|
|
end;
|
|
end;
|
|
|
|
end.
|