2019-11-18 10:36:42 +00:00
|
|
|
unit uViewFacturasCliente;
|
|
|
|
|
|
|
|
|
|
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, uBizFacturasCliente, cxGridCustomPopupMenu,
|
|
|
|
|
cxGridPopupMenu, cxCalendar, cxCurrencyEdit, uViewFiltroBase, TB2Item, TBX,
|
|
|
|
|
TB2Toolbar, TBXDkPanels, TB2Dock, dxPgsDlg, uDAInterfaces, uCustomView,
|
|
|
|
|
uViewBase;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
IViewFacturasCliente = interface(IViewGrid)
|
|
|
|
|
['{927A005F-5D71-4C37-B9E7-10292F9D467C}']
|
|
|
|
|
function GetFacturas: IBizFacturaCliente;
|
|
|
|
|
procedure SetFacturas(const Value: IBizFacturaCliente);
|
|
|
|
|
property Facturas: IBizFacturaCliente read GetFacturas write SetFacturas;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TfrViewFacturasCliente = class(TfrViewGrid, IViewFacturasCliente)
|
|
|
|
|
PngImageList: TPngImageList;
|
|
|
|
|
cxGridViewNOMBRE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewREFERENCIA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewFECHA_FACTURA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewSITUACION: TcxGridDBColumn;
|
|
|
|
|
cxGridViewBASE_IMPONIBLE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewIMPORTE_DESCUENTO: TcxGridDBColumn;
|
|
|
|
|
cxGridViewDESCUENTO: 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_COMISION: TcxGridDBColumn;
|
|
|
|
|
cxStylePendientes: TcxStyle;
|
|
|
|
|
cxStyleParciales: TcxStyle;
|
|
|
|
|
actCliente: TAction;
|
|
|
|
|
actProvincia: TAction;
|
|
|
|
|
TBXItem2: TTBXItem;
|
|
|
|
|
TBXSeparatorItem1: TTBXSeparatorItem;
|
|
|
|
|
TBXItem3: TTBXItem;
|
|
|
|
|
TBXSeparatorItem2: TTBXSeparatorItem;
|
|
|
|
|
cxGridViewTIPO: TcxGridDBColumn;
|
|
|
|
|
cxGridViewTIENDA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewNOMBRE_COMERCIAL: TcxGridDBColumn;
|
|
|
|
|
cxGridViewNOMBRE_CLIENTE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewIMPORTE_RE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewRE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewREF_CONTRATO: TcxGridDBColumn;
|
|
|
|
|
cxGridViewTIPO_FACTURA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewVENDEDOR: TcxGridDBColumn;
|
|
|
|
|
cxGridViewLISTA_NOMBRES: TcxGridDBColumn;
|
2020-03-04 18:16:20 +00:00
|
|
|
cxGridViewLOPD: TcxGridDBColumn;
|
2022-03-31 09:03:49 +00:00
|
|
|
cxGridViewPROCEDENCIA_CLIENTE: TcxGridDBColumn;
|
2025-03-14 18:07:53 +00:00
|
|
|
cxGridViewREF_FORMA_PAGO: TcxGridDBColumn;
|
2019-11-18 10:36:42 +00:00
|
|
|
procedure cxGridViewStylesGetContentStyle(Sender: TcxCustomGridTableView;
|
|
|
|
|
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
|
|
|
|
|
out AStyle: TcxStyle);
|
|
|
|
|
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
|
|
|
|
|
procedure actClienteExecute(Sender: TObject);
|
|
|
|
|
procedure actProvinciaExecute(Sender: TObject);
|
|
|
|
|
procedure actProvinciaUpdate(Sender: TObject);
|
|
|
|
|
procedure actClienteUpdate(Sender: TObject);
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
//Filtros relativos a la vista
|
|
|
|
|
procedure AnadirFiltroSituaciones;
|
|
|
|
|
procedure AnadirFiltroFechas;
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
FFacturas: IBizFacturaCliente;
|
|
|
|
|
function GetFacturas: IBizFacturaCliente;
|
|
|
|
|
procedure SetFacturas(const Value: IBizFacturaCliente);
|
|
|
|
|
|
|
|
|
|
public
|
|
|
|
|
procedure AnadirOtrosFiltros; override;
|
|
|
|
|
property Facturas: IBizFacturaCliente read GetFacturas write SetFacturas;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
uDataModuleFacturasCliente, DateUtils, uViewGridBase;
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
{ TfrViewFacturasCliente }
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasCliente.actClienteExecute(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 TfrViewFacturasCliente.actClienteUpdate(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
(Sender as TAction).Checked := not (cxGridViewNOMBRE.GroupIndex < 0);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasCliente.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 TfrViewFacturasCliente.actProvinciaUpdate(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
(Sender as TAction).Checked := not (cxGridViewPROVINCIA.GroupIndex < 0);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasCliente.AnadirFiltroFechas;
|
|
|
|
|
var
|
|
|
|
|
Columna: TcxGridDBColumn;
|
|
|
|
|
Fecha1, Fecha2: Variant;
|
|
|
|
|
FFiltro : TcxFilterCriteriaItemList;
|
|
|
|
|
begin
|
|
|
|
|
Fecha1 := frViewFiltroBase1.edtFechaIniFiltro.EditValue;
|
|
|
|
|
Fecha2 := frViewFiltroBase1.edtFechaFinFiltro.EditValue;
|
|
|
|
|
|
|
|
|
|
if not VarIsNull(Fecha1)
|
|
|
|
|
and not VarIsNull(Fecha2) then
|
|
|
|
|
begin
|
|
|
|
|
cxGridView.DataController.Filter.Options := [fcoCaseInsensitive, fcoSoftCompare];
|
|
|
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
|
|
|
|
|
|
Columna := (cxGridView as TcxGridDBTableView).GetColumnByFieldName('FECHA_FACTURA');
|
|
|
|
|
FFiltro.AddItem(Columna, foBetween, varArrayOf([Fecha1, Fecha2]), VarToStr(Fecha1) + ' and ' + VarToStr(Fecha2));
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasCliente.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 TfrViewFacturasCliente.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 TfrViewFacturasCliente.cxGridActiveTabChanged(Sender: TcxCustomGrid;
|
|
|
|
|
ALevel: TcxGridLevel);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
RefrescarFiltro;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasCliente.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 := 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 TfrViewFacturasCliente.GetFacturas: IBizFacturaCliente;
|
|
|
|
|
begin
|
|
|
|
|
Result := FFacturas;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewFacturasCliente.SetFacturas(const Value: IBizFacturaCliente);
|
|
|
|
|
begin
|
|
|
|
|
FFacturas := Value;
|
|
|
|
|
if Assigned(FFacturas) then
|
|
|
|
|
dsDataSource.DataTable := FFacturas.DataTable;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|