252 lines
8.4 KiB
ObjectPascal
252 lines
8.4 KiB
ObjectPascal
|
|
unit uViewFacturaProveedor;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uViewBase, DB, uDADataTable, uCustomView,
|
|||
|
|
uViewDatosYSeleccionCliente, uBizFacturasProveedor,
|
|||
|
|
cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit, dxLayoutControl,
|
|||
|
|
cxMemo, cxMaskEdit, cxDropDownEdit, cxCalendar, cxSpinEdit, StdCtrls, Mask,
|
|||
|
|
DBCtrls, cxGraphics, dxLayoutLookAndFeels, cxLookupEdit, cxDBLookupEdit,
|
|||
|
|
cxDBLookupComboBox, uFormasPagoController, uViewDatosYSeleccionProveedor,
|
|||
|
|
uDAInterfaces, uBizFormasPago, uFacturasProveedorController;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IViewFacturaProveedor = interface(IViewBase)
|
|||
|
|
['{DD934441-75CC-452F-8861-684961E90BB6}']
|
|||
|
|
function GetFactura: IBizFacturaProveedor;
|
|||
|
|
procedure SetFactura(const Value: IBizFacturaProveedor);
|
|||
|
|
property Factura: IBizFacturaProveedor read GetFactura write SetFactura;
|
|||
|
|
function GetController : IFacturasProveedorController;
|
|||
|
|
procedure SetController (const Value : IFacturasProveedorController);
|
|||
|
|
property Controller : IFacturasProveedorController read GetController write SetController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfrViewFacturaProveedor = class(TfrViewBase, IViewFacturaProveedor)
|
|||
|
|
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;
|
|||
|
|
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
|
|||
|
|
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
|
|||
|
|
dsFormaPago: TDADataSource;
|
|||
|
|
dxLayoutControl1Item4: TdxLayoutItem;
|
|||
|
|
cbFormaPago: TcxDBLookupComboBox;
|
|||
|
|
dxLayoutControl1Item10: TdxLayoutItem;
|
|||
|
|
bFormasPago: TButton;
|
|||
|
|
dxLayoutControl1Group6: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item6: TdxLayoutItem;
|
|||
|
|
eReferenciaProveedor: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
|||
|
|
frViewProveedorFactura: TfrViewDatosYSeleccionProveedor;
|
|||
|
|
dxLayoutControl1Item7: TdxLayoutItem;
|
|||
|
|
cbCuentaBancaria: TcxDBComboBox;
|
|||
|
|
dxLayoutControl1Group7: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group3: TdxLayoutGroup;
|
|||
|
|
ledtFechaVencimiento: TdxLayoutItem;
|
|||
|
|
edtFechaVencimiento: TcxDBDateEdit;
|
|||
|
|
dxLayoutControl1Group8: TdxLayoutGroup;
|
|||
|
|
procedure bFormasPagoClick(Sender: TObject);
|
|||
|
|
procedure CustomViewDestroy(Sender: TObject);
|
|||
|
|
procedure CustomViewCreate(Sender: TObject);
|
|||
|
|
procedure frViewProveedorFacturaButton1Click(Sender: TObject);
|
|||
|
|
procedure frViewProveedorFacturaButton2Click(Sender: TObject);
|
|||
|
|
procedure cbFormaPagoPropertiesEditValueChanged(Sender: TObject);
|
|||
|
|
|
|||
|
|
protected
|
|||
|
|
FFactura : IBizFacturaProveedor;
|
|||
|
|
FController : IFacturasProveedorController;
|
|||
|
|
FFormasPago : IBizFormaPago;
|
|||
|
|
FFormasPagoController : IFormasPagoController;
|
|||
|
|
function GetFactura: IBizFacturaProveedor;
|
|||
|
|
procedure SetFactura(const Value: IBizFacturaProveedor);
|
|||
|
|
function GetController : IFacturasProveedorController;
|
|||
|
|
procedure SetController (const Value : IFacturasProveedorController);
|
|||
|
|
procedure RellenarCuentasBancarias;
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
property Factura: IBizFacturaProveedor read GetFactura write SetFactura;
|
|||
|
|
property Controller : IFacturasProveedorController read GetController write SetController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uDataModuleContactos, schFacturasProveedorClient_Intf, uFactuGES_App,
|
|||
|
|
uEmpresasController;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
{ TfrViewFacturaProveedor }
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaProveedor.bFormasPagoClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(FFormasPago) then
|
|||
|
|
FFormasPagoController.VerTodos(FFormasPago);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaProveedor.cbFormaPagoPropertiesEditValueChanged(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(FFormasPago) then
|
|||
|
|
if (FFormasPago.Plazos.RecordCount = 0) then
|
|||
|
|
ledtFechaVencimiento.Enabled := True
|
|||
|
|
else
|
|||
|
|
ledtFechaVencimiento.Enabled := False;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaProveedor.CustomViewCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FFormasPago := Nil;
|
|||
|
|
FFormasPagoController := TFormasPagoController.Create;
|
|||
|
|
frViewProveedorFactura.MsgElegirProveedor := 'Elija el proveedor al que se le realizar<61> la factura.';
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaProveedor.CustomViewDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FFormasPago := Nil;
|
|||
|
|
FFormasPagoController := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaProveedor.frViewProveedorFacturaButton1Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Assigned(Factura) and Assigned(Factura.Proveedor) and
|
|||
|
|
Assigned (Factura.Detalles) and (Factura.Detalles.RecordCount > 0) then
|
|||
|
|
begin
|
|||
|
|
if (Application.MessageBox('Si cambia de proveedor, se eliminar<61>n todos sus art<72>culos de la factura actual, <20>Desea continuar?', 'Atenci<63>n', MB_YESNO) = IDNO) then
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
frViewProveedorFactura.actElegirContacto.Execute;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaProveedor.frViewProveedorFacturaButton2Click(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Assigned(Factura) and Assigned(Factura.Proveedor) and
|
|||
|
|
Assigned (Factura.Detalles) and (Factura.Detalles.RecordCount > 0) then
|
|||
|
|
begin
|
|||
|
|
if (Application.MessageBox('Si cambia de proveedor, se eliminar<61>n todos sus art<72>culos de la factura actual, <20>Desea continuar?', 'Atenci<63>n', MB_YESNO) = IDNO) then
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
frViewProveedorFactura.actAnadirContacto.Execute;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewFacturaProveedor.GetController: IFacturasProveedorController;
|
|||
|
|
begin
|
|||
|
|
Result := FController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewFacturaProveedor.GetFactura: IBizFacturaProveedor;
|
|||
|
|
begin
|
|||
|
|
Result := FFactura;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaProveedor.RellenarCuentasBancarias;
|
|||
|
|
var
|
|||
|
|
AController : IEmpresasController;
|
|||
|
|
ALista : TStringList;
|
|||
|
|
AListaIBAN : TStringList;
|
|||
|
|
AListaProveedor : TStringList;
|
|||
|
|
i : integer;
|
|||
|
|
begin
|
|||
|
|
AController := TEmpresasController.Create;
|
|||
|
|
try
|
|||
|
|
ALista := AController.DarListaCuentasBancarias(AppFactuGES.EmpresaActiva);
|
|||
|
|
AListaIBAN := AController.DarListaCuentasBancariasIBAN(AppFactuGES.EmpresaActiva);
|
|||
|
|
AListaProveedor := Controller.ProveedorController.DarListaCuentasBancarias(FFactura.ID_PROVEEDOR);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
with cbCuentaBancaria.Properties.Items do
|
|||
|
|
begin
|
|||
|
|
BeginUpdate;
|
|||
|
|
try
|
|||
|
|
Clear;
|
|||
|
|
Add('');
|
|||
|
|
for i := 0 to ALista.Count - 1 do
|
|||
|
|
Add(ALista.Names[i]);
|
|||
|
|
|
|||
|
|
if AListaIBAN.Count > 0 then
|
|||
|
|
begin
|
|||
|
|
Add('--------------');
|
|||
|
|
for i := 0 to AListaIBAN.Count - 1 do
|
|||
|
|
Add(AListaIBAN.Names[i]);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if AListaProveedor.Count > 0 then
|
|||
|
|
begin
|
|||
|
|
Add('--------------');
|
|||
|
|
for i := 0 to AListaProveedor.Count - 1 do
|
|||
|
|
Add(AListaProveedor.Names[i]);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
finally
|
|||
|
|
EndUpdate;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
FreeANDNIL(ALista);
|
|||
|
|
FreeANDNIL(AListaIBAN);
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
AController := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaProveedor.SetController(const Value: IFacturasProveedorController);
|
|||
|
|
begin
|
|||
|
|
FController := Value;
|
|||
|
|
|
|||
|
|
if Assigned(FController) then
|
|||
|
|
frViewProveedorFactura.Controller := Controller.ProveedorController;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewFacturaProveedor.SetFactura(const Value: IBizFacturaProveedor);
|
|||
|
|
begin
|
|||
|
|
FFactura := Value;
|
|||
|
|
|
|||
|
|
RellenarCuentasBancarias;
|
|||
|
|
|
|||
|
|
if Assigned(FFactura) then
|
|||
|
|
begin
|
|||
|
|
DADataSource.DataTable := FFactura.DataTable;
|
|||
|
|
|
|||
|
|
FFormasPago := FFormasPagoController.BuscarTodos;
|
|||
|
|
dsFormaPago.DataTable := FFormasPago.DataTable;
|
|||
|
|
dsFormaPago.DataTable.Active := True;
|
|||
|
|
|
|||
|
|
//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_FacturasProveedorID, FFactura.ID_FORMA_PAGO, []);
|
|||
|
|
if (FFormasPago.Plazos.RecordCount = 0) then
|
|||
|
|
ledtFechaVencimiento.Enabled := True
|
|||
|
|
else
|
|||
|
|
ledtFechaVencimiento.Enabled := False;
|
|||
|
|
|
|||
|
|
if FFactura.TIPO = CTE_TIPO_ABONO then
|
|||
|
|
begin
|
|||
|
|
dxLayoutControl1Item2.Caption := 'Fecha del abono:';
|
|||
|
|
dxLayoutControl1Group1.Caption := 'Datos del abono';
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
DADataSource.DataTable := NIL;
|
|||
|
|
dsFormaPago.DataTable := NIL;
|
|||
|
|
frViewProveedorFactura.Proveedor := NIL
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|