2007-11-05 18:00:22 +00:00
|
|
|
|
unit uViewFacturaCliente;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uViewBase, DB, uDADataTable, uCustomView,
|
2008-11-06 10:56:45 +00:00
|
|
|
|
uBizFacturasCliente,
|
2007-11-05 18:00:22 +00:00
|
|
|
|
cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit, dxLayoutControl,
|
|
|
|
|
|
cxMemo, cxMaskEdit, cxDropDownEdit, cxCalendar, cxSpinEdit, StdCtrls, Mask,
|
|
|
|
|
|
DBCtrls, cxGraphics, dxLayoutLookAndFeels, cxLookupEdit, cxDBLookupEdit,
|
2008-09-26 14:58:40 +00:00
|
|
|
|
cxDBLookupComboBox, uFormasPagoController, uDAInterfaces, uBizFormasPago,
|
2014-02-18 22:41:52 +00:00
|
|
|
|
ActnList, uViewDatosYSeleccionClienteFacturaCliente, uFacturasClienteController,
|
|
|
|
|
|
cxCheckBox;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
IViewFacturaCliente = interface(IViewBase)
|
|
|
|
|
|
['{3A95930C-20B3-41E9-93CB-21138ADB5B70}']
|
|
|
|
|
|
function GetFactura: IBizFacturaCliente;
|
|
|
|
|
|
procedure SetFactura(const Value: IBizFacturaCliente);
|
|
|
|
|
|
property Factura: IBizFacturaCliente read GetFactura write SetFactura;
|
2008-12-17 19:07:42 +00:00
|
|
|
|
function GetController : IFacturasClienteController;
|
|
|
|
|
|
procedure SetController (const Value : IFacturasClienteController);
|
|
|
|
|
|
property Controller : IFacturasClienteController read GetController write SetController;
|
2008-11-06 10:56:45 +00:00
|
|
|
|
|
|
|
|
|
|
function GetViewClienteFactura: IViewDatosYSeleccionClienteFacturaCliente;
|
|
|
|
|
|
property ViewClienteFactura: IViewDatosYSeleccionClienteFacturaCliente read GetViewClienteFactura;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TfrViewFacturaCliente = class(TfrViewBase, IViewFacturaCliente)
|
|
|
|
|
|
DADataSource: TDADataSource;
|
|
|
|
|
|
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1: TdxLayoutControl;
|
|
|
|
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|
|
|
|
|
eReferencia: TcxDBTextEdit;
|
|
|
|
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
|
|
|
|
|
edtFecha: TcxDBDateEdit;
|
|
|
|
|
|
dxLayoutControl1Group1: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1Group2: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1Item5: TdxLayoutItem;
|
|
|
|
|
|
memObservaciones: TcxDBMemo;
|
|
|
|
|
|
dxLayoutControl1Group5: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1Item6: TdxLayoutItem;
|
|
|
|
|
|
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
|
|
|
|
|
|
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
|
|
|
|
|
|
dsFormaPago: TDADataSource;
|
|
|
|
|
|
dxLayoutControl1Item4: TdxLayoutItem;
|
|
|
|
|
|
cbFormaPago: TcxDBLookupComboBox;
|
|
|
|
|
|
dxLayoutControl1Item10: TdxLayoutItem;
|
|
|
|
|
|
bFormasPago: TButton;
|
2008-06-05 18:21:13 +00:00
|
|
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
|
|
|
|
|
cbCuentaBancaria: TcxDBComboBox;
|
2008-09-26 14:58:40 +00:00
|
|
|
|
dxLayoutControl1Item7: TdxLayoutItem;
|
|
|
|
|
|
Label1: TLabel;
|
|
|
|
|
|
dxLayoutControl1Item8: TdxLayoutItem;
|
|
|
|
|
|
cbClienteFinal: TcxDBTextEdit;
|
|
|
|
|
|
dxLayoutControl1Item9: TdxLayoutItem;
|
|
|
|
|
|
bElegirClienteFinal: TButton;
|
|
|
|
|
|
dxLayoutControl1Group7: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1Group8: TdxLayoutGroup;
|
|
|
|
|
|
ActionList1: TActionList;
|
|
|
|
|
|
actElegirClienteFinal: TAction;
|
2008-11-06 10:56:45 +00:00
|
|
|
|
frViewDatosYSeleccionClienteFacturaCliente1: TfrViewDatosYSeleccionClienteFacturaCliente;
|
|
|
|
|
|
dxLayoutControl1Group9: TdxLayoutGroup;
|
2008-12-17 19:07:42 +00:00
|
|
|
|
dxLayoutControl1Group6: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1Group4: TdxLayoutGroup;
|
|
|
|
|
|
ledtFechaVencimiento: TdxLayoutItem;
|
|
|
|
|
|
edtFechaVemcimiento: TcxDBDateEdit;
|
|
|
|
|
|
dxLayoutControl1Group3: TdxLayoutGroup;
|
2014-02-18 22:41:52 +00:00
|
|
|
|
dxLayoutControl1Item11: TdxLayoutItem;
|
|
|
|
|
|
eCertificadoISO: TcxDBCheckBox;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
procedure bFormasPagoClick(Sender: TObject);
|
|
|
|
|
|
procedure CustomViewDestroy(Sender: TObject);
|
|
|
|
|
|
procedure CustomViewCreate(Sender: TObject);
|
2008-09-26 14:58:40 +00:00
|
|
|
|
procedure actElegirClienteFinalExecute(Sender: TObject);
|
|
|
|
|
|
procedure actElegirClienteFinalUpdate(Sender: TObject);
|
2008-12-17 19:07:42 +00:00
|
|
|
|
procedure edtFechaVemcimientoPropertiesEditValueChanged(Sender: TObject);
|
2007-11-05 18:00:22 +00:00
|
|
|
|
protected
|
|
|
|
|
|
FFactura : IBizFacturaCliente;
|
2008-12-17 19:07:42 +00:00
|
|
|
|
FController : IFacturasClienteController;
|
2007-11-12 19:35:30 +00:00
|
|
|
|
FFormasPago : IBizFormaPago;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
FFormasPagoController : IFormasPagoController;
|
2008-11-06 10:56:45 +00:00
|
|
|
|
FViewClienteFactura : IViewDatosYSeleccionClienteFacturaCliente;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
function GetFactura: IBizFacturaCliente;
|
|
|
|
|
|
procedure SetFactura(const Value: IBizFacturaCliente);
|
2008-12-17 19:07:42 +00:00
|
|
|
|
function GetController : IFacturasClienteController;
|
|
|
|
|
|
procedure SetController (const Value : IFacturasClienteController);
|
2008-06-05 18:21:13 +00:00
|
|
|
|
procedure RellenarCuentasBancarias;
|
2008-11-06 10:56:45 +00:00
|
|
|
|
function GetViewClienteFactura: IViewDatosYSeleccionClienteFacturaCliente;
|
2008-12-17 19:07:42 +00:00
|
|
|
|
|
2007-11-05 18:00:22 +00:00
|
|
|
|
public
|
|
|
|
|
|
property Factura: IBizFacturaCliente read GetFactura write SetFactura;
|
2008-12-17 19:07:42 +00:00
|
|
|
|
property Controller : IFacturasClienteController read GetController write SetController;
|
2008-11-06 10:56:45 +00:00
|
|
|
|
property ViewClienteFactura: IViewDatosYSeleccionClienteFacturaCliente read GetViewClienteFactura;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
2008-06-05 18:21:13 +00:00
|
|
|
|
uDataModuleContactos, schFacturasClienteClient_Intf, uFactuGES_App,
|
2008-09-26 14:58:40 +00:00
|
|
|
|
uEmpresasController, uClientesController, uBizContactos, uBizDireccionesContacto;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{ TfrViewFacturaCliente }
|
|
|
|
|
|
|
2008-09-26 14:58:40 +00:00
|
|
|
|
procedure TfrViewFacturaCliente.actElegirClienteFinalExecute(Sender: TObject);
|
|
|
|
|
|
var
|
|
|
|
|
|
ACliente : IBizCliente;
|
|
|
|
|
|
AClienteController : IClientesController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
AClienteController := TClientesController.Create;
|
|
|
|
|
|
try
|
|
|
|
|
|
ACliente := (AClienteController.ElegirContacto(AClienteController.BuscarTodos,
|
|
|
|
|
|
'Elija el cliente final de esta factura', False) as IBizCliente);
|
|
|
|
|
|
if Assigned(ACliente) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
|
try
|
|
|
|
|
|
FFactura.Edit;
|
|
|
|
|
|
FFactura.CLIENTE_FINAL := ACliente.NOMBRE;
|
|
|
|
|
|
finally
|
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
finally
|
|
|
|
|
|
ACliente := NIL;
|
|
|
|
|
|
AClienteController := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturaCliente.actElegirClienteFinalUpdate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
(Sender as TAction).Enabled := (not ReadOnly);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-11-05 18:00:22 +00:00
|
|
|
|
procedure TfrViewFacturaCliente.bFormasPagoClick(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2007-11-12 19:35:30 +00:00
|
|
|
|
if Assigned(FFormasPago) then
|
|
|
|
|
|
FFormasPagoController.VerTodos(FFormasPago);
|
2007-11-05 18:00:22 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturaCliente.CustomViewCreate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2007-11-12 19:35:30 +00:00
|
|
|
|
FFormasPago := Nil;
|
|
|
|
|
|
FFormasPagoController := TFormasPagoController.Create;
|
2008-11-06 10:56:45 +00:00
|
|
|
|
FViewClienteFactura := frViewDatosYSeleccionClienteFacturaCliente1;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturaCliente.CustomViewDestroy(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2007-11-12 19:35:30 +00:00
|
|
|
|
FFormasPago := Nil;
|
|
|
|
|
|
FFormasPagoController := NIL;
|
2008-11-06 10:56:45 +00:00
|
|
|
|
FViewClienteFactura := NIL;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2008-12-17 19:07:42 +00:00
|
|
|
|
procedure TfrViewFacturaCliente.edtFechaVemcimientoPropertiesEditValueChanged(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
if Assigned(FFormasPago) then
|
|
|
|
|
|
if (FFormasPago.Plazos.RecordCount = 0) then
|
|
|
|
|
|
ledtFechaVencimiento.Enabled := True
|
|
|
|
|
|
else
|
|
|
|
|
|
ledtFechaVencimiento.Enabled := False;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrViewFacturaCliente.GetController: IFacturasClienteController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-11-05 18:00:22 +00:00
|
|
|
|
function TfrViewFacturaCliente.GetFactura: IBizFacturaCliente;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FFactura;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-06 10:56:45 +00:00
|
|
|
|
function TfrViewFacturaCliente.GetViewClienteFactura: IViewDatosYSeleccionClienteFacturaCliente;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FViewClienteFactura;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-06-05 18:21:13 +00:00
|
|
|
|
procedure TfrViewFacturaCliente.RellenarCuentasBancarias;
|
|
|
|
|
|
var
|
|
|
|
|
|
AController : IEmpresasController;
|
|
|
|
|
|
ALista : TStringList;
|
2008-06-12 17:24:02 +00:00
|
|
|
|
AListaIBAN : TStringList;
|
2008-12-17 19:07:42 +00:00
|
|
|
|
AListaCliente: TStringList;
|
2008-06-05 18:21:13 +00:00
|
|
|
|
i : integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AController := TEmpresasController.Create;
|
|
|
|
|
|
try
|
|
|
|
|
|
ALista := AController.DarListaCuentasBancarias(AppFactuGES.EmpresaActiva);
|
2008-06-12 17:24:02 +00:00
|
|
|
|
AListaIBAN := AController.DarListaCuentasBancariasIBAN(AppFactuGES.EmpresaActiva);
|
2008-12-17 19:07:42 +00:00
|
|
|
|
AListaCliente := Controller.ClienteController.DarListaCuentasBancarias(FFactura.ID_CLIENTE);
|
|
|
|
|
|
|
2008-06-05 18:21:13 +00:00
|
|
|
|
try
|
|
|
|
|
|
with cbCuentaBancaria.Properties.Items do
|
|
|
|
|
|
begin
|
|
|
|
|
|
BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
Clear;
|
|
|
|
|
|
Add('');
|
|
|
|
|
|
for i := 0 to ALista.Count - 1 do
|
|
|
|
|
|
Add(ALista.Names[i]);
|
2008-09-24 17:59:34 +00:00
|
|
|
|
|
|
|
|
|
|
if AListaIBAN.Count > 0 then
|
|
|
|
|
|
begin
|
|
|
|
|
|
Add('--------------');
|
|
|
|
|
|
for i := 0 to AListaIBAN.Count - 1 do
|
|
|
|
|
|
Add(AListaIBAN.Names[i]);
|
2008-06-12 17:24:02 +00:00
|
|
|
|
end;
|
2008-12-17 19:07:42 +00:00
|
|
|
|
|
|
|
|
|
|
if AListaCliente.Count > 0 then
|
|
|
|
|
|
begin
|
|
|
|
|
|
Add('--------------');
|
|
|
|
|
|
for i := 0 to AListaCliente.Count - 1 do
|
|
|
|
|
|
Add(AListaCliente.Names[i]);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-06-05 18:21:13 +00:00
|
|
|
|
finally
|
|
|
|
|
|
EndUpdate;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
finally
|
|
|
|
|
|
FreeANDNIL(ALista);
|
2008-06-12 17:24:02 +00:00
|
|
|
|
FreeANDNIL(AListaIBAN);
|
2008-06-05 18:21:13 +00:00
|
|
|
|
end;
|
|
|
|
|
|
finally
|
|
|
|
|
|
AController := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-12-17 19:07:42 +00:00
|
|
|
|
procedure TfrViewFacturaCliente.SetController(const Value: IFacturasClienteController);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FController := Value;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-11-05 18:00:22 +00:00
|
|
|
|
procedure TfrViewFacturaCliente.SetFactura(const Value: IBizFacturaCliente);
|
|
|
|
|
|
var
|
|
|
|
|
|
ACadena : String;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FFactura := Value;
|
2008-06-05 18:21:13 +00:00
|
|
|
|
RellenarCuentasBancarias;
|
2008-11-06 10:56:45 +00:00
|
|
|
|
|
2007-11-05 18:00:22 +00:00
|
|
|
|
if Assigned(FFactura) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
DADataSource.DataTable := FFactura.DataTable;
|
2007-11-12 19:35:30 +00:00
|
|
|
|
|
2009-04-01 11:21:00 +00:00
|
|
|
|
FViewClienteFactura.Factura := FFactura;
|
2008-11-06 10:56:45 +00:00
|
|
|
|
|
2007-11-12 19:35:30 +00:00
|
|
|
|
FFormasPago := FFormasPagoController.BuscarTodos;
|
|
|
|
|
|
dsFormaPago.DataTable := FFormasPago.DataTable;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
dsFormaPago.DataTable.Active := True;
|
2007-11-12 19:35:30 +00:00
|
|
|
|
|
2008-12-17 19:07:42 +00:00
|
|
|
|
//Posicionamos la tabla en la forma de pago que tiene la factura ya que no lo hace el componente por si solo
|
|
|
|
|
|
FFormasPago.DataTable.Locate(fld_FacturasClienteID, FFactura.ID_FORMA_PAGO, []);
|
|
|
|
|
|
if (FFormasPago.Plazos.RecordCount = 0) then
|
|
|
|
|
|
ledtFechaVencimiento.Enabled := True
|
|
|
|
|
|
else
|
|
|
|
|
|
ledtFechaVencimiento.Enabled := False;
|
|
|
|
|
|
|
2007-11-05 18:00:22 +00:00
|
|
|
|
if FFactura.TIPO = CTE_TIPO_ABONO then
|
|
|
|
|
|
begin
|
|
|
|
|
|
dxLayoutControl1Group1.Caption := 'Datos del abono:';
|
|
|
|
|
|
dxLayoutControl1Item2.Caption := 'Fecha del abono:';
|
|
|
|
|
|
ACadena := 'Elija el cliente al que se le realizar<61> el abono.';
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
ACadena := 'Elija el cliente al que se le realizar<61> la factura.';
|
2008-11-06 10:56:45 +00:00
|
|
|
|
//ViewDatosYSeleccionClienteFacturaCliente1.MsgElegirCliente := ACadena;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
end
|
|
|
|
|
|
else begin
|
|
|
|
|
|
DADataSource.DataTable := NIL;
|
|
|
|
|
|
dsFormaPago.DataTable := NIL;
|
2009-04-01 11:21:00 +00:00
|
|
|
|
FViewClienteFactura.Factura := NIL;
|
2007-11-05 18:00:22 +00:00
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|