git-svn-id: https://192.168.0.254/svn/Proyectos.AbetoDesign_FactuGES/trunk@158 93f398dd-4eb6-7a46-baf6-13f46f578da2
130 lines
4.7 KiB
ObjectPascal
130 lines
4.7 KiB
ObjectPascal
unit uViewDetallesDTO;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uViewDetallesBase, cxStyles, cxCustomData, cxGraphics, cxFilter,
|
||
cxData, cxDataStorage, cxEdit, DB, cxDBData, cxImageComboBox, cxRichEdit,
|
||
cxMaskEdit, cxCurrencyEdit, cxCheckBox, ImgList, PngImageList, uDADataTable,
|
||
StdActns, ExtActns, ActnList, TB2Item, TBX, TB2Dock, TB2Toolbar, cxGridLevel,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
|
||
cxControls, cxGridCustomView, cxGrid, ComCtrls, StdCtrls, JvExStdCtrls,
|
||
JvCombobox, JvColorCombo, ToolWin, uDAInterfaces;
|
||
|
||
type
|
||
IViewDetallesDTO = interface(IViewDetallesBase)
|
||
['{0D221FFB-9F43-48FC-9AE7-0AD0F0791AD1}']
|
||
end;
|
||
|
||
TfrViewDetallesDTO = class(TfrViewDetallesBase, IViewDetallesDTO)
|
||
cxGridViewDESCUENTO: TcxGridDBColumn;
|
||
cxGridViewIMPORTEPORTE: TcxGridDBColumn;
|
||
cxGridViewIMPORTENETO: TcxGridDBColumn;
|
||
cxGridViewDECREMENTO: TcxGridDBColumn;
|
||
cxGridViewINCREMENTO: TcxGridDBColumn;
|
||
cxGridViewIMP_UNIDAD_DTO: TcxGridDBColumn;
|
||
procedure cxGridViewIMPORTENETOGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
||
var AText: string);
|
||
procedure cxGridViewIMPORTENETOPropertiesValidate(Sender: TObject;
|
||
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
procedure cxGridViewIMP_UNIDAD_DTOGetDisplayText(
|
||
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
||
var AText: string);
|
||
protected
|
||
function HayQueRecalcular(AItem: TcxCustomGridTableItem): Boolean; override;
|
||
end;
|
||
|
||
implementation
|
||
{$R *.dfm}
|
||
|
||
uses uNumUtils, uCalculosUtils;
|
||
|
||
{ TfrViewDetallesDTO }
|
||
|
||
procedure TfrViewDetallesDTO.cxGridViewIMPORTENETOGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
||
var AText: string);
|
||
var
|
||
ImporteNeto, Incremento, Decremento : Double;
|
||
|
||
begin
|
||
//Se encarga de mostrar el campo calculado de importe neto
|
||
ImporteNeto := -1;
|
||
Incremento := 0;
|
||
Decremento := 0;
|
||
|
||
if not VarIsNull(ARecord.Values[cxGridViewIMPORTEUNIDAD.Index]) then
|
||
begin
|
||
ImporteNeto := ARecord.Values[cxGridViewIMPORTEUNIDAD.Index];
|
||
|
||
if not VarIsNull(ARecord.Values[cxGridViewINCREMENTO.Index]) then
|
||
Incremento := ARecord.Values[cxGridViewINCREMENTO.Index];
|
||
|
||
if not VarIsNull(ARecord.Values[cxGridViewDECREMENTO.Index]) then
|
||
Decremento := ARecord.Values[cxGridViewDECREMENTO.Index];
|
||
|
||
ImporteNeto := CalcularImporteNeto(ARecord.Values[cxGridViewIMPORTEUNIDAD.Index], Incremento, Decremento);
|
||
end;
|
||
|
||
if (ImporteNeto <> -1) then
|
||
begin
|
||
AText := FormatCurr(',0.00 <20>;-,0.00 <20>', FloatToCurr(ImporteNeto))
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewDetallesDTO.cxGridViewIMPORTENETOPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
||
var Error: Boolean);
|
||
begin
|
||
inherited;
|
||
{ if not VarIsNull(DisplayValue) then
|
||
begin
|
||
cxGridViewDESCUENTO.DataBinding.Field.Value := ((cxGridViewIMPORTEUNIDAD.DataBinding.Field.Value - DisplayValue) * 100) / cxGridViewIMPORTEUNIDAD.DataBinding.Field.Value;
|
||
Controller.ActualizarTotales(Detalles);
|
||
end;
|
||
}
|
||
end;
|
||
|
||
procedure TfrViewDetallesDTO.cxGridViewIMP_UNIDAD_DTOGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
||
var AText: string);
|
||
var
|
||
ImporteUnidadDTO, ImporteNeto, Incremento, Decremento, Descuento : Double;
|
||
|
||
begin
|
||
//Se encarga de mostrar el campo calculado de importe neto
|
||
ImporteNeto := -1;
|
||
Incremento := 0;
|
||
Decremento := 0;
|
||
Descuento := 0;
|
||
|
||
if not VarIsNull(ARecord.Values[cxGridViewIMPORTEUNIDAD.Index]) then
|
||
begin
|
||
if not VarIsNull(ARecord.Values[cxGridViewINCREMENTO.Index]) then
|
||
Incremento := ARecord.Values[cxGridViewINCREMENTO.Index];
|
||
|
||
if not VarIsNull(ARecord.Values[cxGridViewDECREMENTO.Index]) then
|
||
Decremento := ARecord.Values[cxGridViewDECREMENTO.Index];
|
||
|
||
ImporteNeto := CalcularImporteNeto(ARecord.Values[cxGridViewIMPORTEUNIDAD.Index], Incremento, Decremento);
|
||
|
||
if not VarIsNull(ARecord.Values[cxGridViewDESCUENTO.Index]) then
|
||
Descuento := ImporteNeto * (ARecord.Values[cxGridViewDESCUENTO.Index]/100);
|
||
|
||
ImporteUnidadDTO := RoundCurrency(ImporteNeto - Descuento);
|
||
end;
|
||
|
||
|
||
if (Descuento <> 0) then
|
||
begin
|
||
AText := FormatCurr(',0.00 <20>;-,0.00 <20>', FloatToCurr(ImporteUnidadDTO))
|
||
end;
|
||
end;
|
||
|
||
function TfrViewDetallesDTO.HayQueRecalcular(AItem: TcxCustomGridTableItem): Boolean;
|
||
begin
|
||
Result := inherited HayQueRecalcular(AItem);
|
||
if not Result then
|
||
Result := (AItem = cxGridViewINCREMENTO) or (AItem = cxGridViewDECREMENTO) or (AItem = cxGridViewDESCUENTO) or (AItem = cxGridViewIMPORTEPORTE);
|
||
end;
|
||
|
||
end.
|