596 lines
19 KiB
ObjectPascal
596 lines
19 KiB
ObjectPascal
|
|
{
|
|||
|
|
===============================================================================
|
|||
|
|
Copyright (<EFBFBD>) 2001. 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: 01-10-2001
|
|||
|
|
Versi<EFBFBD>n actual: 1.0.9
|
|||
|
|
Fecha versi<EFBFBD>n actual: 07-01-2005
|
|||
|
|
===============================================================================
|
|||
|
|
Modificaciones:
|
|||
|
|
|
|||
|
|
Fecha Comentarios
|
|||
|
|
---------------------------------------------------------------------------
|
|||
|
|
09-10-2001 Al pulsar la tecla ESC se activa el bot<EFBFBD>n 'Cancelar'. S<EFBFBD>lo
|
|||
|
|
pasa cuando este frame est<EFBFBD> en una ventana modal.
|
|||
|
|
|
|||
|
|
29-10-2001 Se ha cambiado la etiqueta 'Listado de facturas' por
|
|||
|
|
'Listado de facturas pendientes'.
|
|||
|
|
|
|||
|
|
18-01-2002 Se han coloreado las filas del grid dependiendo de la
|
|||
|
|
situaci<EFBFBD>n de la factura.
|
|||
|
|
|
|||
|
|
07-04-2002 Se ha adaptado para la transacci<EFBFBD>n <EFBFBD>nica.
|
|||
|
|
|
|||
|
|
04-05-2002 Adaptaci<EFBFBD>n al grid 'TdxDBGrid'.
|
|||
|
|
|
|||
|
|
02-08-2002 P233. Poder cambiar la situaci<EFBFBD>n a muchas facturas a la vez.
|
|||
|
|
|
|||
|
|
08-04-2003 P263. Agrupar por a<EFBFBD>os las facturas.
|
|||
|
|
|
|||
|
|
08-03-2004 Al hacer doble click sobre el grid, se pasar<EFBFBD> a modificar el
|
|||
|
|
registro o se seleccionar<EFBFBD>, dependiendo del modo en el que
|
|||
|
|
se encuentre la pantalla.
|
|||
|
|
|
|||
|
|
08-03-2004 p272. Adaptaci<EFBFBD>n a multiempresa.
|
|||
|
|
|
|||
|
|
07-01-2005 Arreglo de informes de facturas pendientes y facturas de iva que
|
|||
|
|
llaman al mismo frame y no cambiaba pero al cambiar entidad solo si funciona.
|
|||
|
|
===============================================================================
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
unit FacturasClientes;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|||
|
|
RdxFrameFacturasCliente, Grids, DBGrids, ComCtrls, RdxBotones, ToolWin, ExtCtrls,
|
|||
|
|
Tipos, Menus, am2000menuitem, am2000popupmenu, am2000, RXDBCtrl,
|
|||
|
|
Db, RdxPaneles, RdxBarras, dxCntner, dxTL, dxDBCtrl, RdxFrame,
|
|||
|
|
dxDBGrid, StdCtrls, RdxComboBox, am2000utils;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrFacturasClientes = class(TRdxFrameFacturasCliente)
|
|||
|
|
dsFacturas: TDataSource;
|
|||
|
|
menuListar: TPopupMenu2000;
|
|||
|
|
MenuItem20002: TMenuItem2000;
|
|||
|
|
MenuItem20004: TMenuItem2000;
|
|||
|
|
MenuItem20005: TMenuItem2000;
|
|||
|
|
BarraFacturas: TRdxBarraSuperior;
|
|||
|
|
bAnadir: TRdxBotonMenu;
|
|||
|
|
bModificar: TRdxBotonSuperior;
|
|||
|
|
bEliminar: TRdxBotonSuperior;
|
|||
|
|
bConsultar: TRdxBotonSuperior;
|
|||
|
|
bBuscar: TRdxBotonSuperior;
|
|||
|
|
bListar: TRdxBotonMenu;
|
|||
|
|
pnlCuerpo: TRdxPanel;
|
|||
|
|
pnlGrid: TRdxPanel;
|
|||
|
|
pnlExtra: TRdxBarraSuperior;
|
|||
|
|
bCambiarSituacion: TRdxBoton;
|
|||
|
|
brSeleccion: TRdxBarraInferior;
|
|||
|
|
bSeleccionar: TRdxBoton;
|
|||
|
|
bCancelarGuardar: TRdxBoton;
|
|||
|
|
brSimple: TRdxBarraInferior;
|
|||
|
|
bSalir: TRdxBoton;
|
|||
|
|
bImprimir: TRdxBoton;
|
|||
|
|
bExportar: TRdxBoton;
|
|||
|
|
gridFacturas: TdxDBGrid;
|
|||
|
|
N1: TMenuItem2000;
|
|||
|
|
Listadefacturasdecliente1: TMenuItem2000;
|
|||
|
|
menuAnadir: TPopupMenu2000;
|
|||
|
|
miFacturaLibre: TMenuItem2000;
|
|||
|
|
miSep1: TMenuItem2000;
|
|||
|
|
miFacturaPre: TMenuItem2000;
|
|||
|
|
miSep2: TMenuItem2000;
|
|||
|
|
miSep3: TMenuItem2000;
|
|||
|
|
miAbono: TMenuItem2000;
|
|||
|
|
miFacturaAlbaran: TMenuItem2000;
|
|||
|
|
imgSombra: TImage;
|
|||
|
|
RdxPanel1: TRdxPanel;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
cbxAno: TRdxComboBox;
|
|||
|
|
bEnviarCorreo: TRdxBoton;
|
|||
|
|
procedure bAnadirClick(Sender: TObject);
|
|||
|
|
procedure bModificarClick(Sender: TObject);
|
|||
|
|
procedure bConsultarClick(Sender: TObject);
|
|||
|
|
procedure bBuscarClick(Sender: TObject);
|
|||
|
|
procedure bEliminarClick(Sender: TObject);
|
|||
|
|
procedure bSeleccionarClick(Sender: TObject);
|
|||
|
|
procedure bCancelarGuardarClick(Sender: TObject);
|
|||
|
|
procedure bSalirClick(Sender: TObject);
|
|||
|
|
procedure MenuItem20002Click(Sender: TObject);
|
|||
|
|
procedure MenuItem20005Click(Sender: TObject);
|
|||
|
|
procedure Listadefacturasdecliente1Click(Sender: TObject);
|
|||
|
|
procedure bCambiarSituacionClick(Sender: TObject);
|
|||
|
|
procedure bImprimirClick(Sender: TObject);
|
|||
|
|
procedure bExportarClick(Sender: TObject);
|
|||
|
|
procedure gridFacturasRefreshButton(Sender: TObject);
|
|||
|
|
procedure gridFacturasCustomDrawCell(Sender: TObject; ACanvas: TCanvas;
|
|||
|
|
ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn;
|
|||
|
|
ASelected, AFocused, ANewItemRow: Boolean; var AText: String;
|
|||
|
|
var AColor: TColor; AFont: TFont; var AAlignment: TAlignment;
|
|||
|
|
var ADone: Boolean);
|
|||
|
|
procedure miAbonoClick(Sender: TObject);
|
|||
|
|
procedure miFacturaAlbaranClick(Sender: TObject);
|
|||
|
|
procedure miFacturaPreClick(Sender: TObject);
|
|||
|
|
procedure miFacturaLibreClick(Sender: TObject);
|
|||
|
|
procedure cbxAnoChange(Sender: TObject);
|
|||
|
|
procedure gridFacturasDblClick(Sender: TObject);
|
|||
|
|
procedure bEnviarCorreoClick(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
FCodigoCliente : String;
|
|||
|
|
FCodigoPresupuesto : String;
|
|||
|
|
FCodigoAlbaran : String;
|
|||
|
|
procedure SetCodigoCliente (Value : String);
|
|||
|
|
procedure ActualizarBotones;
|
|||
|
|
protected
|
|||
|
|
procedure FreeContenido; override;
|
|||
|
|
procedure BuscarFactura; override;
|
|||
|
|
procedure VerModal; override;
|
|||
|
|
procedure SetContenido (NuevoFrame : TRdxFrame); override;
|
|||
|
|
public
|
|||
|
|
constructor Create (AOwner : TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
published
|
|||
|
|
property CodigoCliente : String read FCodigoCliente write SetCodigoCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frFacturasClientes: TfrFacturasClientes;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
{$R *.DFM}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
FacturaCliente, BuscarFacturaCliente, BaseDatos, Configuracion, SysFunc,
|
|||
|
|
IBCustomDataSet, Mensajes, TablaFacturasCliente, RdxEmpresaActiva,
|
|||
|
|
StrFunc, ListadoFacturasCliPenIVA, PagarFacturaCliente, ListadoFacturasCli,
|
|||
|
|
InformeFacturaCliente, RdxFramePresupuestos, PresupuestosClientes,
|
|||
|
|
RdxFrameAlbaranes, AlbaranesClientes, Constantes, Literales,
|
|||
|
|
NumFunc, Correo, TablaClientes;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bAnadirClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
Contenido := TfrFacturaCliente.Create(Self);
|
|||
|
|
Contenido.Modo := Anadir;
|
|||
|
|
Contenido.Visible := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bModificarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
|
|||
|
|
Contenido := TfrFacturaCliente.Create(Self);
|
|||
|
|
Contenido.Modo := Modificar;
|
|||
|
|
Contenido.Visible := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bConsultarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
|
|||
|
|
Contenido := TfrFacturaCliente.Create(Self);
|
|||
|
|
Contenido.Modo := Consultar;
|
|||
|
|
Contenido.Visible := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bBuscarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
|
|||
|
|
Contenido := TfrBuscarFacturaCliente.Create(Self);
|
|||
|
|
Contenido.Visible := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bEliminarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
|
|||
|
|
Contenido := TfrFacturaCliente.Create(Self);
|
|||
|
|
Contenido.Modo := Eliminar;
|
|||
|
|
Contenido.Visible := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.BuscarFactura;
|
|||
|
|
begin
|
|||
|
|
with TablaFacturas do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
Close;
|
|||
|
|
Open;
|
|||
|
|
dmTablaFacturasCliente.InicializarTablaFacturas(@TablaFacturas);
|
|||
|
|
ActualizarBotones;
|
|||
|
|
EnableControls;
|
|||
|
|
if not Locate('CODIGO', CodigoFactura, []) then
|
|||
|
|
gridFacturas.GotoFirst;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfrFacturasClientes.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited Create(AOwner);
|
|||
|
|
Entidad := entFacturaCliente;
|
|||
|
|
ConfigurarFrame(Self, Self.Entidad);
|
|||
|
|
|
|||
|
|
BaseDatos := dmBaseDatos.BD;
|
|||
|
|
Transaccion := dmBaseDatos.Transaccion;
|
|||
|
|
TablaFacturas := TIBDataSet.Create(Self);
|
|||
|
|
dsFacturas.DataSet := TablaFacturas;
|
|||
|
|
|
|||
|
|
with TablaFacturas do
|
|||
|
|
begin
|
|||
|
|
Database := BaseDatos;
|
|||
|
|
Transaction := Transaccion;
|
|||
|
|
SelectSQL.Assign(dmTablaFacturasCliente.sqlConsultarGridFacturas);
|
|||
|
|
ParamByName('CODIGOEMPRESA').AsInteger := EmpresaActiva.Codigo;
|
|||
|
|
Prepare;
|
|||
|
|
Open;
|
|||
|
|
ActualizarBotones;
|
|||
|
|
end;
|
|||
|
|
dmTablaFacturasCliente.InicializarTablaFacturas(@TablaFacturas);
|
|||
|
|
dmTablaFacturasCliente.InicializarGridFacturas(gridFacturas);
|
|||
|
|
gridFacturas.GotoFirst;
|
|||
|
|
|
|||
|
|
cbxAno.Items := dmTablaFacturasCliente.DarListaAnos(EmpresaActiva.Codigo, True);
|
|||
|
|
cbxAno.ItemIndex := 0;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfrFacturasClientes.Destroy;
|
|||
|
|
begin
|
|||
|
|
TablaFacturas.Close;
|
|||
|
|
TablaFacturas.UnPrepare;
|
|||
|
|
TablaFacturas.Free;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.FreeContenido;
|
|||
|
|
begin
|
|||
|
|
if (ContenidoModal is TRdxFramePresupuestos) then
|
|||
|
|
FCodigoPresupuesto := (ContenidoModal as TRdxFramePresupuestos).CodigoPresupuesto;
|
|||
|
|
|
|||
|
|
if (ContenidoModal is TRdxFrameAlbaranes) then
|
|||
|
|
FCodigoAlbaran := (ContenidoModal as TRdxFrameAlbaranes).CodigoAlbaran;
|
|||
|
|
|
|||
|
|
if (Contenido is TRdxFrameFacturasCliente) then
|
|||
|
|
CodigoFactura := (Contenido as TRdxFrameFacturasCliente).CodigoFactura;
|
|||
|
|
inherited FreeContenido;
|
|||
|
|
BuscarFactura;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.SetCodigoCliente(Value: String);
|
|||
|
|
begin
|
|||
|
|
if EsCadenaVacia(Value) then
|
|||
|
|
Exit;
|
|||
|
|
if FCodigoCliente = Value then
|
|||
|
|
exit;
|
|||
|
|
FCodigoCliente := Value;
|
|||
|
|
with TablaFacturas do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
Close;
|
|||
|
|
SelectSQL.Assign(dmTablaFacturasCliente.sqlConsultarGridFacturasCli);
|
|||
|
|
ParamByName('CODIGOEMPRESA').AsInteger := EmpresaActiva.Codigo;
|
|||
|
|
ParamByName('CODIGOCLIENTE').AsString := FCodigoCliente;
|
|||
|
|
Prepare;
|
|||
|
|
Open;
|
|||
|
|
ActualizarBotones;
|
|||
|
|
dmTablaFacturasCliente.InicializarTablaFacturas(@TablaFacturas);
|
|||
|
|
EnableControls;
|
|||
|
|
Locate('CODIGO', CodigoFactura, []);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.VerModal;
|
|||
|
|
begin
|
|||
|
|
if (ContenidoModal is TRdxFramePresupuestos) then
|
|||
|
|
(ContenidoModal as TRdxFramePresupuestos).Modo := Facturar;
|
|||
|
|
|
|||
|
|
if (ContenidoModal is TRdxFrameAlbaranes) then
|
|||
|
|
(ContenidoModal as TRdxFrameAlbaranes).Modo := Facturar;
|
|||
|
|
|
|||
|
|
if (ContenidoModal is TfrPagarFacturaCliente) then
|
|||
|
|
(ContenidoModal as TfrPagarFacturaCliente).ListaFacturas := ListaFacturas;
|
|||
|
|
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bSeleccionarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
|
|||
|
|
CloseFrame;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bCancelarGuardarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
FCodigoFactura := NULL;
|
|||
|
|
CloseFrame;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bSalirClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CloseFrame;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.ActualizarBotones;
|
|||
|
|
begin
|
|||
|
|
if BaseDatos.IsReadOnly then
|
|||
|
|
begin
|
|||
|
|
bAnadir.Enabled := False;
|
|||
|
|
bModificar.Enabled := False;
|
|||
|
|
bEliminar.Enabled := False;
|
|||
|
|
bConsultar.Enabled := True;
|
|||
|
|
bBuscar.Enabled := True;
|
|||
|
|
bListar.Enabled := True;
|
|||
|
|
bCambiarSituacion.Enabled := False;
|
|||
|
|
bImprimir.Enabled := True;
|
|||
|
|
bExportar.Enabled := True;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if TablaFacturas.RecordCount = 0 then
|
|||
|
|
begin
|
|||
|
|
bAnadir.Enabled := True;
|
|||
|
|
bModificar.Enabled := False;
|
|||
|
|
bEliminar.Enabled := False;
|
|||
|
|
bConsultar.Enabled := False;
|
|||
|
|
bBuscar.Enabled := False;
|
|||
|
|
bListar.Enabled := False;
|
|||
|
|
bCambiarSituacion.Enabled := False;
|
|||
|
|
bImprimir.Enabled := False;
|
|||
|
|
bExportar.Enabled := False;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
bAnadir.Enabled := True;
|
|||
|
|
bModificar.Enabled := True;
|
|||
|
|
bEliminar.Enabled := True;
|
|||
|
|
bConsultar.Enabled := True;
|
|||
|
|
bBuscar.Enabled := True;
|
|||
|
|
bListar.Enabled := True;
|
|||
|
|
bCambiarSituacion.Enabled := True;
|
|||
|
|
bImprimir.Enabled := True;
|
|||
|
|
bExportar.Enabled := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.MenuItem20002Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
Contenido := TfrListadoFacturasCliPenIVA.Create(Self);
|
|||
|
|
Contenido.Entidad := entListadoFacturasCliPendientes;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.MenuItem20005Click(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
ContenidoAux : TfrListadoFacturasCliPenIVA;
|
|||
|
|
begin
|
|||
|
|
Contenido := TfrListadoFacturasCliPenIVA.Create(Self);
|
|||
|
|
Contenido.Entidad := entListadoFacturasCliIVA;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bCambiarSituacionClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
Situacion : String;
|
|||
|
|
iAux : Integer;
|
|||
|
|
begin
|
|||
|
|
ListaFacturas := dmTablaFacturasCliente.DarListaFacturas(gridFacturas, @TablaFacturas);
|
|||
|
|
if (ListaFacturas = NIL) or (ListaFacturas.Count = 0) then
|
|||
|
|
exit;
|
|||
|
|
|
|||
|
|
// Comprobar que todas las facturas tienen la misma situaci<63>n
|
|||
|
|
for iAux := 0 to ListaFacturas.Count - 1 do
|
|||
|
|
begin
|
|||
|
|
if iAux = 0 then
|
|||
|
|
Situacion := dmTablaFacturasCliente.DarSituacionFactura(EmpresaActiva.Codigo, ListaFacturas.Strings[iAux])
|
|||
|
|
else begin
|
|||
|
|
if Situacion <> dmTablaFacturasCliente.DarSituacionFactura(EmpresaActiva.Codigo, ListaFacturas.Strings[iAux]) then
|
|||
|
|
begin
|
|||
|
|
VerMensaje(msgFacSitDistinta);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
CaptionModal := 'Cambiar situaci<63>n de factura de cliente';
|
|||
|
|
WidthModal := 460;
|
|||
|
|
HeightModal := 200;
|
|||
|
|
ModoModal := Pagar;
|
|||
|
|
EntidadModal := entCliente;
|
|||
|
|
ContenidoModal := TfrPagarFacturaCliente.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bImprimirClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
FInformeFactura : TInformeFacturaCliente;
|
|||
|
|
begin
|
|||
|
|
CodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
|
|||
|
|
FInformeFactura := TInformeFacturaCliente.Create(Self);
|
|||
|
|
try
|
|||
|
|
FInformeFactura.Imprimir(FCodigoFactura);
|
|||
|
|
finally
|
|||
|
|
FInformeFactura.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bExportarClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
FInformeFactura : TInformeFacturaCliente;
|
|||
|
|
Fichero : String;
|
|||
|
|
begin
|
|||
|
|
if not DarFicheroExportar(Fichero) then
|
|||
|
|
Exit;
|
|||
|
|
CodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
|
|||
|
|
FInformeFactura := TInformeFacturaCliente.Create(Self);
|
|||
|
|
try
|
|||
|
|
FInformeFactura.Exportar(FCodigoFactura, Fichero);
|
|||
|
|
finally
|
|||
|
|
FInformeFactura.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.gridFacturasRefreshButton(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
BuscarFactura;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.gridFacturasCustomDrawCell(Sender: TObject;
|
|||
|
|
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
|
|||
|
|
AColumn: TdxTreeListColumn; ASelected, AFocused, ANewItemRow: Boolean;
|
|||
|
|
var AText: String; var AColor: TColor; AFont: TFont;
|
|||
|
|
var AAlignment: TAlignment; var ADone: Boolean);
|
|||
|
|
var
|
|||
|
|
IndiceCol : Integer;
|
|||
|
|
begin
|
|||
|
|
if not ASelected then
|
|||
|
|
begin
|
|||
|
|
IndiceCol := (Sender as TdxDBGrid).ColumnByFieldName('SITUACION').Index;
|
|||
|
|
if UpperCase(ANode.Strings[IndiceCol]) = 'PAGADA' then
|
|||
|
|
AFont.Color := COLOR_PAGADO;
|
|||
|
|
IndiceCol := (Sender as TdxDBGrid).ColumnByFieldName('CLASEFACTURA').Index;
|
|||
|
|
if UpperCase(ANode.Strings[IndiceCol]) = 'A' then
|
|||
|
|
AFont.Color := COLOR_ABONO;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.Listadefacturasdecliente1Click(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
Contenido := TfrListadoFacturasCli.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.miAbonoClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
|
|||
|
|
|
|||
|
|
// Mirar si la factura seleccionada es un cargo
|
|||
|
|
if (dmTablaFacturasCliente.DarClaseFactura(EmpresaActiva.Codigo, CodigoFactura) <> 'C') then
|
|||
|
|
begin
|
|||
|
|
VerMensaje(msgFacCliClaseFacDistinta);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
// Mirar si la factura est<73> totalmente abonada
|
|||
|
|
if (Redondear(abs(dmTablaFacturasCliente.DarImporteTodosAbonos(EmpresaActiva.Codigo, CodigoFactura)), 2) >=
|
|||
|
|
Redondear(abs(TablaFacturas.FieldByName('IMPORTETOTAL').AsFloat), 2)) then
|
|||
|
|
begin
|
|||
|
|
VerMensaje(msgFacTotalmenteAbonada);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
// Mostrar la pantalla de altas
|
|||
|
|
Contenido := TfrFacturaCliente.Create(Self);
|
|||
|
|
Contenido.Modo := Anadir;
|
|||
|
|
(Contenido as TfrFacturaCliente).CodigoFacturaCargo := CodigoFactura;
|
|||
|
|
Contenido.Visible := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.miFacturaAlbaranClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
// Mostrar la lista de albaranes
|
|||
|
|
CaptionModal := 'Elija el albar<61>n que desea facturar';
|
|||
|
|
ContenidoModal := TfrAlbaranesClientes.Create(Self);
|
|||
|
|
|
|||
|
|
if (not EsCadenaVacia(FCodigoAlbaran)) then
|
|||
|
|
begin
|
|||
|
|
Contenido := TfrFacturaCliente.Create(Self);
|
|||
|
|
Contenido.Modo := Anadir;
|
|||
|
|
(Contenido as TfrFacturaCliente).CodigoAlbaran := FCodigoAlbaran;
|
|||
|
|
Contenido.Visible := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.miFacturaPreClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
// Mostrar la lista de presupuestos
|
|||
|
|
CaptionModal := 'Elija el presupuesto que desea facturar';
|
|||
|
|
ContenidoModal := TfrPresupuestosClientes.Create(Self);
|
|||
|
|
|
|||
|
|
if (not EsCadenaVacia(FCodigoPresupuesto)) then
|
|||
|
|
begin
|
|||
|
|
Contenido := TfrFacturaCliente.Create(Self);
|
|||
|
|
Contenido.Modo := Anadir;
|
|||
|
|
(Contenido as TfrFacturaCliente).CodigoPresupuesto := FCodigoPresupuesto;
|
|||
|
|
Contenido.Visible := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.miFacturaLibreClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
Contenido := TfrFacturaCliente.Create(Self);
|
|||
|
|
Contenido.Modo := Anadir;
|
|||
|
|
Contenido.Visible := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.cbxAnoChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if cbxAno.Text = CTE_TODOS then begin
|
|||
|
|
gridFacturas.Filter.Remove(gridFacturas.FindColumnByFieldName(CTE_ANO));
|
|||
|
|
gridFacturas.Filter.Clear;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
gridFacturas.Filter.Clear;
|
|||
|
|
gridFacturas.Filter.Add(gridFacturas.FindColumnByFieldName(CTE_ANO), cbxAno.Text, cbxAno.Text);
|
|||
|
|
|
|||
|
|
//Para activar P255
|
|||
|
|
// gridFacturas.Filter.Add(gridFacturas.FindColumnByFieldName('MES'), '1/2002', '1/2002');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
gridFacturas.SetFocus;
|
|||
|
|
gridFacturas.GotoFirst;
|
|||
|
|
//Falta seleccionar tupla
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.gridFacturasDblClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Modo = Seleccionar then
|
|||
|
|
bSeleccionar.Click
|
|||
|
|
else
|
|||
|
|
bModificar.Click;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.SetContenido(NuevoFrame: TRdxFrame);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if (Contenido is TfrListadoFacturasCli) then
|
|||
|
|
(Contenido as TfrListadoFacturasCli).CodigoCliente := TablaFacturas.FieldByName('CODIGOCLIENTE').AsString;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrFacturasClientes.bEnviarCorreoClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
FInforme : TInformeFacturaCliente;
|
|||
|
|
Fichero : String;
|
|||
|
|
Datos: TDatosCorreo;
|
|||
|
|
CodigoCliente: String;
|
|||
|
|
|
|||
|
|
begin
|
|||
|
|
CodigoFactura := TablaFacturas.FieldByName('CODIGO').AsString;
|
|||
|
|
CodigoCliente := TablaFacturas.FieldByName('CODIGOCLIENTE').AsString;
|
|||
|
|
Datos:= Nil;
|
|||
|
|
Fichero := CodigoFactura;
|
|||
|
|
Fichero := DarRutaTemporal + StringReplace(Fichero, CTE_SEPSERIADO, CTE_SEPSERIADO2, [rfReplaceAll, rfIgnoreCase]);
|
|||
|
|
Fichero := Fichero + CTE_DOC;
|
|||
|
|
|
|||
|
|
//Generamos el fichero para luego adjuntaro al correo
|
|||
|
|
FInforme:= TInformeFacturaCliente.Create(Self);
|
|||
|
|
try
|
|||
|
|
FInforme.Exportar(CodigoFactura, Fichero);
|
|||
|
|
finally
|
|||
|
|
FInforme.Free;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
//Creamos el correo
|
|||
|
|
Datos:= TDatosCorreo.Create;
|
|||
|
|
Datos.Direcciones.add(dmTablaClientes.darCorreo(CodigoCliente));
|
|||
|
|
Datos.Adjuntos.Add(Fichero);
|
|||
|
|
enviarCorreo(Datos);
|
|||
|
|
finally
|
|||
|
|
FreeAndNil(Datos);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|