This repository has been archived on 2024-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
AlonsoYSal_FactuGES/Modulos/Contactos/Cliente/uDataModuleComisiones.pas

160 lines
4.4 KiB
ObjectPascal
Raw Blame History

unit uDataModuleComisiones;
interface
uses {vcl:} SysUtils, Classes, DB, DBClient,
{RemObjects:} uDAClientDataModule, uDADataTable, uDABINAdapter,
uROServiceComponent, uRORemoteService, uROClient, uROBinMessage,
uROWinInetHttpChannel, uDataModuleBase, uDAScriptingProvider,
uDACDSDataTable, uBizComisiones, uDADesigntimeCall;
type
TdmComisiones = class(TDAClientDataModule)
RORemoteService: TRORemoteService;
DABinAdapter: TDABINAdapter;
tbl_VENDEDORESCOMISION: TDACDSDataTable;
ds_VENDEDORESCOMISION: TDADataSource;
LoginRemoteService: TRORemoteService;
DADesigntimeCall1: TDADesigntimeCall;
ROWinInetHTTPChannel1: TROWinInetHTTPChannel;
ROBinMessage1: TROBinMessage;
tbl_COBROSCOMISION: TDACDSDataTable;
ds_COBROSCOMISION: TDADataSource;
procedure DAClientDataModuleCreate(Sender: TObject);
private
function GetVendedoresComision: IBizVendedoresComision;
public
function GetComision(Codigo : Integer): Float;
procedure SetComision(Codigo : Integer; Comision : Float);
procedure CalcularComisiones;
function GetCobrosComision(FechaInicial, FechaFinal : TDateTime; const Tipo: String): IBizCobrosComision;
end;
var
dmComisiones: TdmComisiones;
implementation
uses FactuGES_Intf, DataAbstract_Intf, uDAInterfaces, Controls, forms, uDataTableUtils,
uGUIBase, uEditorComisiones, schComisionesClient_Intf;
{$R *.DFM}
{ TdmComisiones }
procedure TdmComisiones.CalcularComisiones;
var
aObj: IEditorComisiones;
begin
aObj := TfEditorComisiones.Create(Application);
try
with aObj do
begin
ShowModal;
end;
finally
aObj := NIL;
end;
end;
procedure TdmComisiones.DAClientDataModuleCreate(Sender: TObject);
begin
RORemoteService.Channel := dmBase.ROChannel;
RORemoteService.Message := dmBase.ROMessage;
end;
function TdmComisiones.GetCobrosComision(FechaInicial, FechaFinal: TDateTime; const Tipo: String): IBizCobrosComision;
var
dtCobrosComision: TDACDSDataTable;
AParams : TDADatasetParamArray;
ACursor: TCursor;
begin
ACursor := Screen.Cursor;
Screen.Cursor := crHourGlass;
try
dtCobrosComision := TDACDSDataTable.Create(NIL);
CloneDataTable(tbl_CobrosCOMISION, dtCobrosComision);
with dtCobrosComision do
begin
BusinessRulesID := BIZ_CobrosCOMISION;
FieldByName(fld_CobrosCOMISIONSELECCION).BusinessRulesID := BIZ_SELECCION;
AParams := TDADatasetParamArray.Create;
with AParams.Add do begin
Name := 'FECHAINI';
Value := FechaInicial;
end;
with AParams.Add do begin
Name := 'FECHAFIN';
Value := FechaFinal;
end;
DataRequestCall.ParamByName(par_Params).AsComplexType := AParams;
end;
if Tipo = 'Cocina' then
begin
with dtCobrosComision.Where do
begin
AddOperator(opAND);
OpenBraket;
AddText('V_TIPOS_PAGO.' + fld_COBROSCOMISIONTIPO + ' = ''Cocina''', False);
CloseBraket;
end;
end
else if Tipo = 'Ba<42>o' then
begin
with dtCobrosComision.Where do
begin
AddOperator(opAND);
OpenBraket;
AddText('V_TIPOS_PAGO.' + fld_COBROSCOMISIONTIPO + ' = ''Ba<42>o''', False);
CloseBraket;
end;
end;
(dtCobrosComision as IBizCobrosComision).VendedoresComision := GetVendedoresComision;
Result := (dtCobrosComision as IBizCobrosComision);
finally
Screen.Cursor := ACursor;
end;
end;
function TdmComisiones.GetComision(Codigo: Integer): Float;
begin
Result := (RORemoteService as IsrvComisiones).GetComision(Codigo);
end;
function TdmComisiones.GetVendedoresComision: IBizVendedoresComision;
var
dtVendedoresComision: TDACDSDataTable;
ACursor: TCursor;
begin
ACursor := Screen.Cursor;
Screen.Cursor := crHourGlass;
try
dtVendedoresComision := TDACDSDataTable.Create(NIL);
CloneDataTable(tbl_VENDEDORESCOMISION, dtVendedoresComision);
dtVendedoresComision.BusinessRulesID := BIZ_VENDEDORESCOMISION;
Result := (dtVendedoresComision as IBizVendedoresComision);
finally
Screen.Cursor := ACursor;
end;
end;
procedure TdmComisiones.SetComision(Codigo: Integer; Comision: Float);
begin
(RORemoteService as IsrvComisiones).SetComision(Codigo, Comision);
end;
initialization
dmComisiones := TdmComisiones.Create(nil);
finalization
FreeAndNil(dmComisiones);
end.