2019-11-18 10:36:42 +00:00
|
|
|
|
unit uViewRecibosCliente;
|
|
|
|
|
|
|
|
|
|
|
|
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, uBizRecibosCliente, cxGridCustomPopupMenu,
|
|
|
|
|
|
cxGridPopupMenu, cxCalendar, cxCurrencyEdit, uViewFiltroBase, TB2Item, TBX,
|
|
|
|
|
|
TB2Toolbar, TBXDkPanels, TB2Dock, dxPgsDlg, uDAInterfaces, uCustomView,
|
|
|
|
|
|
uViewBase;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
IViewRecibosCliente = interface(IViewGrid)
|
|
|
|
|
|
['{27D0229A-6340-4F03-B97A-7776E9166F2F}']
|
|
|
|
|
|
function GetRecibos: IBizRecibosCliente;
|
|
|
|
|
|
procedure SetRecibos(const Value: IBizRecibosCliente);
|
|
|
|
|
|
property Recibos: IBizRecibosCliente read GetRecibos write SetRecibos;
|
|
|
|
|
|
|
|
|
|
|
|
procedure FiltrarPorFechas(const Fecha1, Fecha2: Variant);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TfrViewRecibosCliente = class(TfrViewGrid, IViewRecibosCliente)
|
|
|
|
|
|
PngImageList: TPngImageList;
|
|
|
|
|
|
cxStylePendientes: TcxStyle;
|
|
|
|
|
|
cxGridPendientes: TcxGridLevel;
|
|
|
|
|
|
cxGridPagados: TcxGridLevel;
|
|
|
|
|
|
cxStylePagados: TcxStyle;
|
|
|
|
|
|
cxGridViewREFERENCIA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewSITUACION: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewFECHA_VENCIMIENTO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewDESCRIPCION: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewIMPORTE: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewNOMBRE_CLIENTE: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewNIF_CIF: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewREFERENCIA_REMESA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridDevueltos: TcxGridLevel;
|
|
|
|
|
|
cxGridViewOTROS_GASTOS: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewIMPORTE_TOTAL: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewFECHA_EMISION: TcxGridDBColumn;
|
|
|
|
|
|
cxStyleDevueltos: TcxStyle;
|
|
|
|
|
|
actCliente: TAction;
|
|
|
|
|
|
TBXItem2: TTBXItem;
|
|
|
|
|
|
TBXSeparatorItem1: TTBXSeparatorItem;
|
|
|
|
|
|
cxGridViewREFERENCIA_REC_COMPENSADO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewID_RECIBO_COMPENSADO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewTIENDA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewID_TIENDA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewNOMBRE: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewCALLE: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewPOBLACION: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewPROVINCIA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewCODIGO_POSTAL: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewCUENTA_CONTABLE: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewLISTA_NOMBRES: TcxGridDBColumn;
|
2020-01-23 18:43:09 +00:00
|
|
|
|
cxGridViewREFERENCIA_CONTRATO: TcxGridDBColumn;
|
2021-03-04 14:07:54 +00:00
|
|
|
|
cxGridViewFECHA_PAGO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewSUBCUENTA: 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 cxGridViewIMPORTE_TOTALGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
|
|
|
|
|
var AText: string);
|
|
|
|
|
|
procedure actClienteExecute(Sender: TObject);
|
|
|
|
|
|
procedure actClienteUpdate(Sender: TObject);
|
|
|
|
|
|
procedure cxGridViewID_RECIBO_COMPENSADOCustomDrawCell(
|
|
|
|
|
|
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
|
|
|
|
|
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
//Filtros relativos a la vista
|
|
|
|
|
|
procedure AnadirFiltroSituaciones;
|
|
|
|
|
|
procedure AnadirFiltroFechas;
|
|
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
FRecibos: IBizRecibosCliente;
|
|
|
|
|
|
function GetRecibos: IBizRecibosCliente;
|
|
|
|
|
|
procedure SetRecibos(const Value: IBizRecibosCliente);
|
|
|
|
|
|
procedure AnadirOtrosFiltros; override;
|
|
|
|
|
|
|
|
|
|
|
|
public
|
|
|
|
|
|
property Recibos: IBizRecibosCliente read GetRecibos write SetRecibos;
|
|
|
|
|
|
procedure FiltrarPorFechas(const Fecha1, Fecha2: Variant);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
schRecibosClienteClient_Intf, uDataModuleRecibosCliente, DateUtils;
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{ TfrViewRecibosCliente }
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewRecibosCliente.actClienteExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (cxGridViewNOMBRE_CLIENTE.GroupIndex < 0) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
cxGridViewNOMBRE_CLIENTE.GroupIndex := cxGridView.GroupedColumnCount;
|
|
|
|
|
|
cxGridViewNOMBRE_CLIENTE.Visible := False;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
begin
|
|
|
|
|
|
cxGridViewNOMBRE_CLIENTE.GroupIndex := -1;
|
|
|
|
|
|
cxGridViewNOMBRE_CLIENTE.Visible := True;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewRecibosCliente.actClienteUpdate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
(Sender as TAction).Checked := not (cxGridViewNOMBRE_CLIENTE.GroupIndex < 0);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewRecibosCliente.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(fld_RecibosClienteFECHA_VENCIMIENTO);
|
|
|
|
|
|
FFiltro.AddItem(Columna, foBetween, varArrayOf([Fecha1, Fecha2]), VarToStr(Fecha1) + ' and ' + VarToStr(Fecha2));
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewRecibosCliente.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_COBRADO, CTE_COBRADO);
|
|
|
|
|
|
3 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, CTE_DEVUELTO, CTE_DEVUELTO);
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewRecibosCliente.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 TfrViewRecibosCliente.cxGridActiveTabChanged(Sender: TcxCustomGrid;
|
|
|
|
|
|
ALevel: TcxGridLevel);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
RefrescarFiltro;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewRecibosCliente.cxGridViewID_RECIBO_COMPENSADOCustomDrawCell(
|
|
|
|
|
|
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
|
|
|
|
|
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|
|
|
|
|
var
|
|
|
|
|
|
R : TRect;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if not VarIsNull(AViewInfo.Value) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
R := AViewInfo.ContentBounds;
|
|
|
|
|
|
ACanvas.FillRect(R);
|
|
|
|
|
|
ACanvas.DrawImage(PngImageList, R.Left, R.Top, 2);
|
|
|
|
|
|
ADone := True;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewRecibosCliente.cxGridViewIMPORTE_TOTALGetDisplayText(
|
|
|
|
|
|
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
|
|
|
|
|
var AText: string);
|
|
|
|
|
|
var
|
|
|
|
|
|
ImporteTotal : Double;
|
|
|
|
|
|
begin
|
|
|
|
|
|
//Se encarga de mostrar el campo calculado de importe total
|
|
|
|
|
|
ImporteTotal := -1;
|
|
|
|
|
|
|
|
|
|
|
|
if not VarIsNull(ARecord.Values[cxGridViewIMPORTE.Index]) then
|
|
|
|
|
|
if not VarIsNull(ARecord.Values[cxGridViewOTROS_GASTOS.Index]) then
|
|
|
|
|
|
ImporteTotal := ARecord.Values[cxGridViewIMPORTE.Index] + ARecord.Values[cxGridViewOTROS_GASTOS.Index]
|
|
|
|
|
|
else
|
|
|
|
|
|
ImporteTotal := ARecord.Values[cxGridViewIMPORTE.Index];
|
|
|
|
|
|
|
|
|
|
|
|
if (ImporteTotal <> -1) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
AText := FormatCurr(',0.00 €;-,0.00 €', FloatToCurr(ImporteTotal));
|
|
|
|
|
|
|
|
|
|
|
|
ARecord.Values[cxGridViewIMPORTE_TOTAL.Index] := ImporteTotal;
|
|
|
|
|
|
cxGridViewIMPORTE_TOTAL.EditValue := ImporteTotal;
|
|
|
|
|
|
cxGridViewIMPORTE_TOTAL.DataBinding.Field.Value := ImporteTotal;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewRecibosCliente.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_PENDIENTE) then
|
|
|
|
|
|
AStyle := cxStylePendientes
|
|
|
|
|
|
else if (ASituacion = CTE_COBRADO) then
|
|
|
|
|
|
AStyle := cxStylePagados
|
|
|
|
|
|
else if (ASituacion = CTE_DEVUELTO) then
|
|
|
|
|
|
AStyle := cxStyleDevueltos;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewRecibosCliente.FiltrarPorFechas(const Fecha1, Fecha2: Variant);
|
|
|
|
|
|
var
|
|
|
|
|
|
Columna: TcxGridDBColumn;
|
|
|
|
|
|
begin
|
|
|
|
|
|
with cxGridView.DataController.Filter do
|
|
|
|
|
|
begin
|
|
|
|
|
|
BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
Options := [fcoCaseInsensitive, fcoSoftCompare];
|
|
|
|
|
|
Root.Clear;
|
|
|
|
|
|
if not VarIsNull(Fecha1)
|
|
|
|
|
|
and not VarIsNull(Fecha2) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
Columna := (cxGridView as TcxGridDBTableView).GetColumnByFieldName(fld_RecibosClienteFECHA_VENCIMIENTO);
|
|
|
|
|
|
Root.AddItem(Columna, foBetween, varArrayOf([Fecha1, Fecha2]), VarToStr(Fecha1) + ' and ' + VarToStr(Fecha2));
|
|
|
|
|
|
Active := True;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
Active := False;
|
|
|
|
|
|
finally
|
|
|
|
|
|
EndUpdate;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrViewRecibosCliente.GetRecibos: IBizRecibosCliente;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FRecibos;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewRecibosCliente.SetRecibos(const Value: IBizRecibosCliente);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FRecibos := Value;
|
|
|
|
|
|
if Assigned(FRecibos) then
|
|
|
|
|
|
dsDataSource.DataTable := FRecibos.DataTable;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|