2007-06-21 16:02:50 +00:00
|
|
|
|
unit uViewFacturaCliente;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uViewBase, DB, uDADataTable, uCustomView,
|
|
|
|
|
|
uViewDatosYSeleccionContacto, uViewDatosFacturaCliente,
|
|
|
|
|
|
uViewObservaciones, uViewFormaPago, AppEvnts, uBizFacturasCliente,
|
|
|
|
|
|
cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit,
|
|
|
|
|
|
uViewAlbaranRelacionado, uViewAlbaranFactura;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
IViewFacturaCliente = interface(IViewBase)
|
|
|
|
|
|
['{3A95930C-20B3-41E9-93CB-21138ADB5B70}']
|
|
|
|
|
|
function GetFacturaCliente: IBizFacturasCliente;
|
|
|
|
|
|
procedure SetFacturaCliente(const Value: IBizFacturasCliente);
|
|
|
|
|
|
property FacturaCliente: IBizFacturasCliente read GetFacturaCliente
|
|
|
|
|
|
write SetFacturaCliente;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TfrViewFacturaCliente = class(TfrViewBase, IViewFacturaCliente)
|
|
|
|
|
|
DADataSource: TDADataSource;
|
|
|
|
|
|
frViewDatosYSeleccionContacto1: TfrViewDatosYSeleccionContacto;
|
|
|
|
|
|
frViewObservaciones1: TfrViewObservaciones;
|
|
|
|
|
|
frViewFormaPago1: TfrViewFormaPago;
|
|
|
|
|
|
frViewDatosFacturaCliente1: TfrViewDatosFacturaCliente;
|
|
|
|
|
|
frViewAlbaranFactura1: TfrViewAlbaranFactura;
|
|
|
|
|
|
procedure frViewDatosYSeleccionContacto1actElegirContactoExecute(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
procedure frViewDatosYSeleccionContacto1actAnadirContactoExecute(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
procedure frViewDatosYSeleccionContacto1actVerContactoExecute(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
procedure frViewDatosYSeleccionContacto1edtlNombrePropertiesEditValueChanged(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
private
|
|
|
|
|
|
FFacturaCliente : IBizFacturasCliente;
|
|
|
|
|
|
procedure OnContactoChanged (Sender : TObject);
|
|
|
|
|
|
procedure OnAlbaranChanged(Sender : TObject);
|
|
|
|
|
|
protected
|
|
|
|
|
|
function GetFacturaCliente: IBizFacturasCliente;
|
|
|
|
|
|
procedure SetFacturaCliente(const Value: IBizFacturasCliente);
|
|
|
|
|
|
public
|
|
|
|
|
|
property FacturaCliente: IBizFacturasCliente read GetFacturaCliente
|
|
|
|
|
|
write SetFacturaCliente;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
|
frViewFacturaCliente: TfrViewFacturaCliente;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
uses uBizContacto, uExceptions, uDataModuleContactos,
|
|
|
|
|
|
schFacturasClienteClient_Intf, uDataModuleAlbaranesCliente;
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{ TfrViewFacturaCliente }
|
|
|
|
|
|
|
|
|
|
|
|
function TfrViewFacturaCliente.GetFacturaCliente: IBizFacturasCliente;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FFacturaCliente;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturaCliente.OnContactoChanged(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FFacturaCliente.Cliente := (frViewDatosYSeleccionContacto1.Contacto as IBizCliente);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturaCliente.SetFacturaCliente(
|
|
|
|
|
|
const Value: IBizFacturasCliente);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FFacturaCliente := Value;
|
|
|
|
|
|
if Assigned(FFacturaCliente) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
DADataSource.DataTable := FFacturaCliente.DataTable;
|
|
|
|
|
|
|
|
|
|
|
|
//Solo se deshabilita al insertar, luego la referencia ser<65> modificable
|
|
|
|
|
|
if FFacturaCliente.DataTable.State = dsInsert then
|
|
|
|
|
|
frViewDatosFacturaCliente1.eReferencia.Enabled := False;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
DADataSource.DataTable := NIL;
|
|
|
|
|
|
|
|
|
|
|
|
frViewDatosFacturaCliente1.DADataSource.DataTable := DADataSource.DataTable;
|
|
|
|
|
|
frViewObservaciones1.DADataSource.DataTable := DADataSource.DataTable;
|
|
|
|
|
|
frViewFormaPago1.DADataSource.DataTable := DADataSource.DataTable;
|
|
|
|
|
|
|
|
|
|
|
|
frViewDatosYSeleccionContacto1.Contacto := FFacturaCliente.Cliente;
|
|
|
|
|
|
frViewDatosYSeleccionContacto1.OnContactoChanged := OnContactoChanged;
|
|
|
|
|
|
|
|
|
|
|
|
frViewAlbaranFactura1.Albaran := dmAlbaranesCliente.GetItem(FFacturaCliente.CODIGOALBARAN);
|
|
|
|
|
|
frViewAlbaranFactura1.OnAlbaranChanged := OnAlbaranChanged;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturaCliente.frViewDatosYSeleccionContacto1actElegirContactoExecute(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
frViewDatosYSeleccionContacto1.actElegirContactoExecute(Sender);
|
|
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturaCliente.frViewDatosYSeleccionContacto1actAnadirContactoExecute(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
frViewDatosYSeleccionContacto1.actAnadirContactoExecute(Sender);
|
|
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturaCliente.frViewDatosYSeleccionContacto1actVerContactoExecute(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
var
|
|
|
|
|
|
AContacto : IBizCliente;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
AContacto := dmContactos.GetCliente(FFacturaCliente.CODIGOCONTACTO);
|
|
|
|
|
|
try
|
2014-07-14 17:22:53 +00:00
|
|
|
|
if Assigned(AContacto) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
AContacto.DataTable.Open;
|
|
|
|
|
|
if (AContacto.DataTable.RecordCount = 0) or (AContacto.BAJA_LOGICA = 1) then
|
|
|
|
|
|
ShowMessage('La ficha ha sido eliminada de programa.')
|
|
|
|
|
|
else
|
|
|
|
|
|
AContacto.Show;
|
|
|
|
|
|
end;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
finally
|
|
|
|
|
|
AContacto := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturaCliente.frViewDatosYSeleccionContacto1edtlNombrePropertiesEditValueChanged(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
with (Sender as TcxDBTextEdit) do
|
|
|
|
|
|
Enabled := (FFacturaCliente.CODIGOCONTACTO <> 0)
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturaCliente.OnAlbaranChanged(Sender: TObject);
|
|
|
|
|
|
var
|
|
|
|
|
|
DesglosarIVA : Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if not (FFacturaCliente.DataTable.State in dsEditModes) then
|
|
|
|
|
|
FFacturaCliente.Edit;
|
|
|
|
|
|
|
|
|
|
|
|
FFacturaCliente.CopyFrom(frViewAlbaranFactura1.Albaran);
|
|
|
|
|
|
frViewDatosYSeleccionContacto1.Contacto := FFacturaCliente.Cliente;
|
|
|
|
|
|
|
|
|
|
|
|
// <20>Desglosar el IVA?
|
|
|
|
|
|
if Application.MessageBox('<27>Desea desglosar el IVA a partir del albar<61>n?', 'Atenci<63>n', MB_YESNO) = IDYES then
|
|
|
|
|
|
FFacturaCliente.DesglosarIVA
|
|
|
|
|
|
else
|
|
|
|
|
|
MessageBox(0, 'Se ha copiado correctamente el albar<61>n elegido en esta factura.', 'Albar<61>n copiado', MB_ICONWARNING or MB_OK);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|