2011-11-14 17:40:41 +00:00
|
|
|
|
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;
|
2022-03-12 10:40:36 +00:00
|
|
|
|
cxGridViewDECREMENTO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewINCREMENTO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewIMP_UNIDAD_DTO: TcxGridDBColumn;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
procedure cxGridViewIMPORTENETOGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
|
|
|
|
|
var AText: string);
|
|
|
|
|
|
procedure cxGridViewIMPORTENETOPropertiesValidate(Sender: TObject;
|
|
|
|
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
2022-03-12 10:40:36 +00:00
|
|
|
|
procedure cxGridViewIMP_UNIDAD_DTOGetDisplayText(
|
|
|
|
|
|
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
|
|
|
|
|
var AText: string);
|
2011-11-14 17:40:41 +00:00
|
|
|
|
protected
|
|
|
|
|
|
function HayQueRecalcular(AItem: TcxCustomGridTableItem): Boolean; override;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
2022-03-12 10:40:36 +00:00
|
|
|
|
uses uNumUtils, uCalculosUtils;
|
|
|
|
|
|
|
2011-11-14 17:40:41 +00:00
|
|
|
|
{ TfrViewDetallesDTO }
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesDTO.cxGridViewIMPORTENETOGetDisplayText(Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
|
|
|
|
|
var AText: string);
|
|
|
|
|
|
var
|
2022-03-12 10:40:36 +00:00
|
|
|
|
ImporteNeto, Incremento, Decremento : Double;
|
2022-06-23 15:49:41 +00:00
|
|
|
|
NumDecimales : Smallint;
|
2022-03-12 10:40:36 +00:00
|
|
|
|
|
2011-11-14 17:40:41 +00:00
|
|
|
|
begin
|
|
|
|
|
|
//Se encarga de mostrar el campo calculado de importe neto
|
|
|
|
|
|
ImporteNeto := -1;
|
2022-03-12 10:40:36 +00:00
|
|
|
|
Incremento := 0;
|
|
|
|
|
|
Decremento := 0;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
|
2022-06-23 15:49:41 +00:00
|
|
|
|
NumDecimales := TcxCurrencyEditProperties(Sender.Properties).DecimalPlaces;
|
|
|
|
|
|
|
2011-11-14 17:40:41 +00:00
|
|
|
|
if not VarIsNull(ARecord.Values[cxGridViewIMPORTEUNIDAD.Index]) then
|
2022-03-12 10:40:36 +00:00
|
|
|
|
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];
|
|
|
|
|
|
|
2022-06-23 15:49:41 +00:00
|
|
|
|
ImporteNeto := CalcularImporteNeto(ARecord.Values[cxGridViewIMPORTEUNIDAD.Index], Incremento, Decremento, NumDecimales);
|
2022-03-12 10:40:36 +00:00
|
|
|
|
end;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
|
|
|
|
|
|
if (ImporteNeto <> -1) then
|
|
|
|
|
|
begin
|
2022-06-23 15:49:41 +00:00
|
|
|
|
if (NumDecimales = 2) then
|
|
|
|
|
|
AText := FormatCurr(',0.00 <20>;-,0.00 <20>', FloatToCurr(ImporteNeto))
|
|
|
|
|
|
else
|
|
|
|
|
|
AText := FormatCurr(',0.0000 <20>;-,0.0000 <20>', FloatToCurr(ImporteNeto))
|
2011-11-14 17:40:41 +00:00
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesDTO.cxGridViewIMPORTENETOPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|
|
|
|
|
var Error: Boolean);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2022-03-12 10:40:36 +00:00
|
|
|
|
{ if not VarIsNull(DisplayValue) then
|
2011-11-14 17:40:41 +00:00
|
|
|
|
begin
|
|
|
|
|
|
cxGridViewDESCUENTO.DataBinding.Field.Value := ((cxGridViewIMPORTEUNIDAD.DataBinding.Field.Value - DisplayValue) * 100) / cxGridViewIMPORTEUNIDAD.DataBinding.Field.Value;
|
|
|
|
|
|
Controller.ActualizarTotales(Detalles);
|
|
|
|
|
|
end;
|
2022-03-12 10:40:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesDTO.cxGridViewIMP_UNIDAD_DTOGetDisplayText( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
|
|
|
|
|
var AText: string);
|
|
|
|
|
|
var
|
|
|
|
|
|
ImporteUnidadDTO, ImporteNeto, Incremento, Decremento, Descuento : Double;
|
2022-06-23 15:49:41 +00:00
|
|
|
|
NumDecimales : Smallint;
|
2022-03-12 10:40:36 +00:00
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
//Se encarga de mostrar el campo calculado de importe neto
|
|
|
|
|
|
ImporteNeto := -1;
|
|
|
|
|
|
Incremento := 0;
|
|
|
|
|
|
Decremento := 0;
|
|
|
|
|
|
Descuento := 0;
|
|
|
|
|
|
|
2022-06-23 15:49:41 +00:00
|
|
|
|
NumDecimales := TcxCurrencyEditProperties(Sender.Properties).DecimalPlaces;
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-12 10:40:36 +00:00
|
|
|
|
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];
|
|
|
|
|
|
|
2022-06-23 15:49:41 +00:00
|
|
|
|
ImporteNeto := CalcularImporteNeto(ARecord.Values[cxGridViewIMPORTEUNIDAD.Index], Incremento, Decremento, NumDecimales);
|
2022-03-12 10:40:36 +00:00
|
|
|
|
|
|
|
|
|
|
if not VarIsNull(ARecord.Values[cxGridViewDESCUENTO.Index]) then
|
|
|
|
|
|
Descuento := ImporteNeto * (ARecord.Values[cxGridViewDESCUENTO.Index]/100);
|
|
|
|
|
|
|
2022-06-23 15:49:41 +00:00
|
|
|
|
ImporteUnidadDTO := RoundCurrency((ImporteNeto - Descuento), NumDecimales)
|
2022-03-12 10:40:36 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Descuento <> 0) then
|
|
|
|
|
|
begin
|
2022-06-23 15:49:41 +00:00
|
|
|
|
if (NumDecimales = 2) then
|
|
|
|
|
|
AText := FormatCurr(',0.00 <20>;-,0.00 <20>', FloatToCurr(ImporteUnidadDTO))
|
|
|
|
|
|
else
|
|
|
|
|
|
AText := FormatCurr(',0.0000 <20>;-,0.0000 <20>', FloatToCurr(ImporteUnidadDTO))
|
2022-03-12 10:40:36 +00:00
|
|
|
|
end;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrViewDetallesDTO.HayQueRecalcular(AItem: TcxCustomGridTableItem): Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := inherited HayQueRecalcular(AItem);
|
|
|
|
|
|
if not Result then
|
2022-03-12 10:40:36 +00:00
|
|
|
|
Result := (AItem = cxGridViewINCREMENTO) or (AItem = cxGridViewDECREMENTO) or (AItem = cxGridViewDESCUENTO) or (AItem = cxGridViewIMPORTEPORTE);
|
2011-11-14 17:40:41 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|