2019-11-18 10:36:42 +00:00
|
|
|
unit uViewFacturasProveedor;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
Dialogs, uViewGrid, uViewPreview, cxStyles, cxCustomData, cxGraphics,
|
|
|
|
|
cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, dxPSGlbl, dxPSUtl,
|
|
|
|
|
dxPSEngn, dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider,
|
|
|
|
|
dxPSFillPatterns, dxPSEdgePatterns, cxImageComboBox, cxTextEdit, ImgList,
|
|
|
|
|
PngImageList, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
|
|
|
|
dxPSCore, dxPScxCommon, dxPScxGrid6Lnk, ActnList, uDADataTable,
|
|
|
|
|
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGrid,
|
|
|
|
|
cxImage, Grids, DBGrids, uBizFacturasProveedor, cxGridCustomPopupMenu,
|
|
|
|
|
cxGridPopupMenu, cxCalendar, cxCurrencyEdit, uViewFiltroBase, TB2Item, TBX,
|
|
|
|
|
TB2Toolbar, TBXDkPanels, TB2Dock, dxPgsDlg, uDAInterfaces, uCustomView,
|
|
|
|
|
uViewBase;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
IViewFacturasProveedor = interface(IViewGrid)
|
|
|
|
|
['{F0015E71-D890-4266-B7F4-7BCB38AFA0DE}']
|
|
|
|
|
function GetFacturas: IBizFacturaProveedor;
|
|
|
|
|
procedure SetFacturas(const Value: IBizFacturaProveedor);
|
|
|
|
|
property Facturas: IBizFacturaProveedor read GetFacturas write SetFacturas;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TfrViewFacturasProveedor = class(TfrViewGrid, IViewFacturasProveedor)
|
|
|
|
|
PngImageList: TPngImageList;
|
|
|
|
|
cxGridViewNOMBRE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewREFERENCIA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewFECHA_FACTURA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewSITUACION: TcxGridDBColumn;
|
|
|
|
|
cxGridViewBASE_IMPONIBLE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewIMPORTE_RE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewRE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewIMPORTE_IVA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewIMPORTE_TOTAL: TcxGridDBColumn;
|
|
|
|
|
cxGridViewIVA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewNIF_CIF: TcxGridDBColumn;
|
|
|
|
|
cxGridViewCALLE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewPROVINCIA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewCODIGO_POSTAL: TcxGridDBColumn;
|
|
|
|
|
cxGridViewPOBLACION: TcxGridDBColumn;
|
|
|
|
|
cxStylePagada: TcxStyle;
|
|
|
|
|
cxGridPendientes: TcxGridLevel;
|
|
|
|
|
cxGridParcial: TcxGridLevel;
|
|
|
|
|
cxStyleAbono: TcxStyle;
|
|
|
|
|
cxGridPagadas: TcxGridLevel;
|
|
|
|
|
cxGridViewREFERENCIA_PROVEEDOR: TcxGridDBColumn;
|
|
|
|
|
cxStylePendientes: TcxStyle;
|
|
|
|
|
cxStyleParciales: TcxStyle;
|
|
|
|
|
actProveedor: TAction;
|
|
|
|
|
actProvincia: TAction;
|
|
|
|
|
TBXItem2: TTBXItem;
|
|
|
|
|
TBXSeparatorItem1: TTBXSeparatorItem;
|
|
|
|
|
TBXItem3: TTBXItem;
|
|
|
|
|
TBXSeparatorItem2: TTBXSeparatorItem;
|
|
|
|
|
cxGridViewTIPO: TcxGridDBColumn;
|
|
|
|
|
cxGridViewTIENDA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewNOMBRE_PROVEEDOR: TcxGridDBColumn;
|
|
|
|
|
cxGridViewNOMBRE_COMERCIAL: TcxGridDBColumn;
|
|
|
|
|
cxGridViewFECHA_VENCIMIENTO: TcxGridDBColumn;
|
|
|
|
|
procedure cxGridViewStylesGetContentStyle(Sender: TcxCustomGridTableView;
|
|
|
|
|
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
|
|
|
|
|
out AStyle: TcxStyle);
|
|
|
|
|
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
|
|
|
|
|
procedure actProveedorExecute(Sender: TObject);
|
|
|
|
|
procedure actProveedorUpdate(Sender: TObject);
|
|
|
|
|
procedure actProvinciaExecute(Sender: TObject);
|
|
|
|
|
procedure actProvinciaUpdate(Sender: TObject);
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
//Filtros relativos a la vista
|
|
|
|
|
procedure AnadirFiltroSituaciones;
|
|
|
|
|
procedure AnadirFiltroFechas;
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
FFacturas: IBizFacturaProveedor;
|
|
|
|
|
function GetFacturas: IBizFacturaProveedor;
|
|
|
|
|
procedure SetFacturas(const Value: IBizFacturaProveedor);
|
|
|
|
|
public
|
|
|
|
|
procedure AnadirOtrosFiltros; override;
|
|
|
|
|
property Facturas: IBizFacturaProveedor read GetFacturas write SetFacturas;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
uDataModuleFacturasProveedor, DateUtils, uViewGridBase;
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
{ TfrViewFacturasProveedor }
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasProveedor.actProveedorExecute(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
if (cxGridViewNOMBRE.GroupIndex < 0) then
|
|
|
|
|
begin
|
|
|
|
|
cxGridViewNOMBRE.GroupIndex := cxGridView.GroupedColumnCount;
|
|
|
|
|
cxGridViewNOMBRE.Visible := False;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
cxGridViewNOMBRE.GroupIndex := -1;
|
|
|
|
|
cxGridViewNOMBRE.Visible := True;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasProveedor.actProveedorUpdate(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
(Sender as TAction).Checked := not (cxGridViewNOMBRE.GroupIndex < 0);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasProveedor.actProvinciaExecute(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
if (cxGridViewPROVINCIA.GroupIndex < 0) then
|
|
|
|
|
begin
|
|
|
|
|
cxGridViewPROVINCIA.GroupIndex := cxGridView.GroupedColumnCount;
|
|
|
|
|
cxGridViewPROVINCIA.Visible := False;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
cxGridViewPROVINCIA.GroupIndex := -1;
|
|
|
|
|
cxGridViewPROVINCIA.Visible := True;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasProveedor.actProvinciaUpdate(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
(Sender as TAction).Checked := not (cxGridViewPROVINCIA.GroupIndex < 0);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasProveedor.AnadirFiltroFechas;
|
|
|
|
|
var
|
|
|
|
|
Columna: TcxGridDBColumn;
|
|
|
|
|
Fecha1, Fecha2: Variant;
|
2020-03-03 18:07:32 +00:00
|
|
|
FechaVto1, FechaVto2: Variant;
|
2019-11-18 10:36:42 +00:00
|
|
|
FFiltro : TcxFilterCriteriaItemList;
|
|
|
|
|
begin
|
|
|
|
|
Fecha1 := frViewFiltroBase1.edtFechaIniFiltro.EditValue;
|
|
|
|
|
Fecha2 := frViewFiltroBase1.edtFechaFinFiltro.EditValue;
|
|
|
|
|
|
2020-03-03 18:07:32 +00:00
|
|
|
FechaVto1 := frViewFiltroBase1.edtFecha2IniFiltro.EditValue;
|
|
|
|
|
FechaVto2 := frViewFiltroBase1.edtFecha2FinFiltro.EditValue;
|
|
|
|
|
|
2019-11-18 10:36:42 +00:00
|
|
|
if not VarIsNull(Fecha1)
|
|
|
|
|
and not VarIsNull(Fecha2) then
|
|
|
|
|
begin
|
|
|
|
|
cxGridView.DataController.Filter.Options := [fcoCaseInsensitive, fcoSoftCompare];
|
|
|
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
|
|
2020-03-03 18:07:32 +00:00
|
|
|
Columna := (cxGridView as TcxGridDBTableView).GetColumnByFieldName('FECHA_FACTURA');
|
2019-11-18 10:36:42 +00:00
|
|
|
FFiltro.AddItem(Columna, foBetween, varArrayOf([Fecha1, Fecha2]), VarToStr(Fecha1) + ' and ' + VarToStr(Fecha2));
|
|
|
|
|
end;
|
2020-03-03 18:07:32 +00:00
|
|
|
|
|
|
|
|
if not VarIsNull(FechaVto1)
|
|
|
|
|
and not VarIsNull(FechaVto2) then
|
|
|
|
|
begin
|
|
|
|
|
cxGridView.DataController.Filter.Options := [fcoCaseInsensitive, fcoSoftCompare];
|
|
|
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
|
|
|
|
|
|
Columna := (cxGridView as TcxGridDBTableView).GetColumnByFieldName('FECHA_VENCIMIENTO');
|
|
|
|
|
FFiltro.AddItem(Columna, foBetween, varArrayOf([FechaVto1, FechaVto2]), VarToStr(FechaVto1) + ' and ' + VarToStr(FechaVto2));
|
|
|
|
|
end;
|
|
|
|
|
|
2019-11-18 10:36:42 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasProveedor.AnadirFiltroSituaciones;
|
|
|
|
|
var
|
|
|
|
|
FFiltro : TcxFilterCriteriaItemList;
|
|
|
|
|
begin
|
|
|
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
|
|
|
|
|
|
case cxGrid.ActiveLevel.Index of
|
|
|
|
|
1 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, CTE_PENDIENTE, CTE_PENDIENTE);
|
|
|
|
|
2 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, CTE_PARCIAMENTE_PAGADA, CTE_PARCIAMENTE_PAGADA);
|
|
|
|
|
3 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, CTE_PAGADA, CTE_PAGADA);
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasProveedor.AnadirOtrosFiltros;
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
|
|
AnadirFiltroSituaciones;
|
|
|
|
|
AnadirFiltroFechas;
|
|
|
|
|
|
|
|
|
|
//Finalmente activamos el filtro si tenemos algo
|
|
|
|
|
if cxGridView.DataController.Filter.IsEmpty
|
|
|
|
|
then cxGridView.DataController.Filter.Active := False
|
|
|
|
|
else cxGridView.DataController.Filter.Active := True;
|
|
|
|
|
cxGrid.ActiveLevel.GridView := cxGridView;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasProveedor.cxGridActiveTabChanged(Sender: TcxCustomGrid;
|
|
|
|
|
ALevel: TcxGridLevel);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
RefrescarFiltro;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasProveedor.cxGridViewStylesGetContentStyle(
|
|
|
|
|
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
|
|
|
|
|
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
|
|
|
|
|
var
|
|
|
|
|
IndiceCol: Integer;
|
|
|
|
|
ASituacion: string;
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
|
|
if Assigned(ARecord) then
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
|
|
IndiceCol := cxGridViewSITUACION.Index;
|
|
|
|
|
ASituacion := UPPERCASE(VarToStr(ARecord.DisplayTexts[IndiceCol]));
|
|
|
|
|
if (ASituacion = CTE_PAGADA) then
|
|
|
|
|
AStyle := cxStylePagada
|
|
|
|
|
else if (ASituacion = CTE_PENDIENTE) then
|
|
|
|
|
AStyle := cxStylePendientes
|
|
|
|
|
else if (ASituacion = CTE_PARCIAMENTE_PAGADA) then
|
|
|
|
|
AStyle := cxStyleParciales;
|
|
|
|
|
|
|
|
|
|
IndiceCol := cxGridViewIMPORTE_TOTAL.Index;
|
|
|
|
|
if (Pos('-', ARecord.DisplayTexts[IndiceCol]) > 0) then
|
|
|
|
|
AStyle := cxStyleAbono;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TfrViewFacturasProveedor.GetFacturas: IBizFacturaProveedor;
|
|
|
|
|
begin
|
|
|
|
|
Result := FFacturas;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasProveedor.SetFacturas(const Value: IBizFacturaProveedor);
|
|
|
|
|
begin
|
|
|
|
|
FFacturas := Value;
|
|
|
|
|
if Assigned(FFacturas) then
|
|
|
|
|
dsDataSource.DataTable := FFacturas.DataTable;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|
|
|
|
|
|