Facturas de cliente: informe en formato Word (sin terminar).

git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@269 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
David Arranz 2008-02-07 22:07:23 +00:00
parent 1ee166c21e
commit da8de64743
11 changed files with 1063 additions and 16 deletions

Binary file not shown.

View File

@ -0,0 +1,611 @@
object RptWordFacturaCliente: TRptWordFacturaCliente
OldCreateOrder = False
OnCreate = DataModuleCreate
Height = 245
Width = 341
object schReport: TDASchema
ConnectionManager = dmServer.ConnectionManager
DataDictionary = DataDictionary
Datasets = <
item
Params = <
item
Name = 'ID'
Value = ''
ParamType = daptInput
end>
Statements = <
item
Connection = 'IBX'
SQL =
'select'#10' v_facturas_cliente.id, v_facturas_cliente.id_empresa,'#10 +
' v_facturas_cliente.referencia, v_facturas_cliente.tipo,'#10' v_' +
'facturas_cliente.fecha_factura, v_facturas_cliente.base_imponibl' +
'e,'#10' v_facturas_cliente.situacion, v_facturas_cliente.descuento' +
','#10' v_facturas_cliente.importe_descuento, v_facturas_cliente.iv' +
'a,'#10' v_facturas_cliente.importe_iva, v_facturas_cliente.re,'#10' ' +
'v_facturas_cliente.importe_re, v_facturas_cliente.importe_total,' +
#10' v_facturas_cliente.observaciones, v_facturas_cliente.nif_cif' +
','#10' v_facturas_cliente.id_cliente, v_facturas_cliente.nombre,'#10' ' +
' v_facturas_cliente.calle, v_facturas_cliente.provincia,'#10' v_f' +
'acturas_cliente.poblacion, v_facturas_cliente.codigo_postal,'#10' ' +
'v_facturas_cliente.recargo_equivalencia, v_facturas_cliente.impo' +
'rte_neto,'#10' v_facturas_cliente.importe_porte, formas_pago.descr' +
'ipcion as FORMA_PAGO'#10'from v_facturas_cliente'#10' left outer join ' +
'formas_pago on (formas_pago.id = v_facturas_cliente.id_forma_pag' +
'o)'#10'WHERE V_FACTURAS_CLIENTE.ID = :ID'#10
StatementType = stSQL
ColumnMappings = <
item
DatasetField = 'ID'
TableField = 'ID'
end
item
DatasetField = 'ID_EMPRESA'
TableField = 'ID_EMPRESA'
end
item
DatasetField = 'REFERENCIA'
TableField = 'REFERENCIA'
end
item
DatasetField = 'OBSERVACIONES'
TableField = 'OBSERVACIONES'
end
item
DatasetField = 'ID_CLIENTE'
TableField = 'ID_CLIENTE'
end
item
DatasetField = 'NIF_CIF'
TableField = 'NIF_CIF'
end
item
DatasetField = 'NOMBRE'
TableField = 'NOMBRE'
end
item
DatasetField = 'IMPORTE_TOTAL'
TableField = 'IMPORTE_TOTAL'
end
item
DatasetField = 'CALLE'
TableField = 'CALLE'
end
item
DatasetField = 'POBLACION'
TableField = 'POBLACION'
end
item
DatasetField = 'PROVINCIA'
TableField = 'PROVINCIA'
end
item
DatasetField = 'CODIGO_POSTAL'
TableField = 'CODIGO_POSTAL'
end
item
DatasetField = 'TIPO'
TableField = 'TIPO'
end
item
DatasetField = 'FECHA_FACTURA'
TableField = 'FECHA_FACTURA'
end
item
DatasetField = 'BASE_IMPONIBLE'
TableField = 'BASE_IMPONIBLE'
end
item
DatasetField = 'SITUACION'
TableField = 'SITUACION'
end
item
DatasetField = 'DESCUENTO'
TableField = 'DESCUENTO'
end
item
DatasetField = 'IMPORTE_DESCUENTO'
TableField = 'IMPORTE_DESCUENTO'
end
item
DatasetField = 'IVA'
TableField = 'IVA'
end
item
DatasetField = 'IMPORTE_IVA'
TableField = 'IMPORTE_IVA'
end
item
DatasetField = 'RE'
TableField = 'RE'
end
item
DatasetField = 'IMPORTE_RE'
TableField = 'IMPORTE_RE'
end
item
DatasetField = 'RECARGO_EQUIVALENCIA'
TableField = 'RECARGO_EQUIVALENCIA'
end
item
DatasetField = 'IMPORTE_NETO'
TableField = 'IMPORTE_NETO'
end
item
DatasetField = 'IMPORTE_PORTE'
TableField = 'IMPORTE_PORTE'
end
item
DatasetField = 'FORMA_PAGO'
TableField = 'FORMA_PAGO'
end>
end>
Name = 'Informe_Cabecera'
Fields = <
item
Name = 'ID'
DataType = datInteger
Required = True
InPrimaryKey = True
end
item
Name = 'ID_EMPRESA'
DataType = datInteger
end
item
Name = 'REFERENCIA'
DataType = datString
Size = 255
end
item
Name = 'TIPO'
DataType = datString
Size = 1
end
item
Name = 'FECHA_FACTURA'
DataType = datDateTime
end
item
Name = 'BASE_IMPONIBLE'
DataType = datCurrency
end
item
Name = 'SITUACION'
DataType = datString
Size = 19
end
item
Name = 'DESCUENTO'
DataType = datFloat
end
item
Name = 'IMPORTE_DESCUENTO'
DataType = datCurrency
end
item
Name = 'IVA'
DataType = datFloat
end
item
Name = 'IMPORTE_IVA'
DataType = datCurrency
end
item
Name = 'RE'
DataType = datFloat
end
item
Name = 'IMPORTE_RE'
DataType = datCurrency
end
item
Name = 'IMPORTE_TOTAL'
DataType = datCurrency
end
item
Name = 'OBSERVACIONES'
DataType = datMemo
end
item
Name = 'NIF_CIF'
DataType = datString
Size = 15
end
item
Name = 'ID_CLIENTE'
DataType = datInteger
end
item
Name = 'NOMBRE'
DataType = datString
Size = 255
end
item
Name = 'CALLE'
DataType = datString
Size = 255
end
item
Name = 'PROVINCIA'
DataType = datString
Size = 255
end
item
Name = 'POBLACION'
DataType = datString
Size = 255
end
item
Name = 'CODIGO_POSTAL'
DataType = datString
Size = 10
end
item
Name = 'RECARGO_EQUIVALENCIA'
DataType = datSmallInt
end
item
Name = 'IMPORTE_NETO'
DataType = datCurrency
end
item
Name = 'IMPORTE_PORTE'
DataType = datCurrency
end
item
Name = 'FORMA_PAGO'
DataType = datString
Size = 255
end>
ReadOnly = True
end
item
Params = <
item
Name = 'ID_FACTURA'
Value = ''
ParamType = daptInput
end>
Statements = <
item
Connection = 'IBX'
ConnectionType = 'Interbase'
Default = True
SQL =
'SELECT'#10' ID, ID_FACTURA, POSICION, TIPO_DETALLE, CONCEPTO, CAN' +
'TIDAD,'#10' IMPORTE_UNIDAD, DESCUENTO, IMPORTE_TOTAL, VISIBLE'#10'FRO' +
'M FACTURAS_CLIENTE_DETALLES'#10'WHERE ID_FACTURA = :ID_FACTURA AND V' +
'ISIBLE = 1 AND {Where}'#10'ORDER BY ID_FACTURA, POSICION;'#10
StatementType = stSQL
ColumnMappings = <
item
DatasetField = 'ID'
TableField = 'ID'
end
item
DatasetField = 'POSICION'
TableField = 'POSICION'
end
item
DatasetField = 'TIPO_DETALLE'
TableField = 'TIPO_DETALLE'
end
item
DatasetField = 'CONCEPTO'
TableField = 'CONCEPTO'
end
item
DatasetField = 'IMPORTE_TOTAL'
TableField = 'IMPORTE_TOTAL'
end
item
DatasetField = 'CANTIDAD'
TableField = 'CANTIDAD'
end
item
DatasetField = 'IMPORTE_UNIDAD'
TableField = 'IMPORTE_UNIDAD'
end
item
DatasetField = 'ID_FACTURA'
TableField = 'ID_FACTURA'
end
item
DatasetField = 'DESCUENTO'
TableField = 'DESCUENTO'
end
item
DatasetField = 'VISIBLE'
TableField = 'VISIBLE'
end>
end>
Name = 'Informe_Detalles'
Fields = <
item
Name = 'ID'
DataType = datInteger
InPrimaryKey = True
end
item
Name = 'ID_FACTURA'
DataType = datInteger
end
item
Name = 'POSICION'
DataType = datInteger
end
item
Name = 'TIPO_DETALLE'
DataType = datString
Size = 10
end
item
Name = 'CONCEPTO'
DataType = datString
Size = 2000
end
item
Name = 'CANTIDAD'
DataType = datInteger
end
item
Name = 'IMPORTE_UNIDAD'
DataType = datCurrency
end
item
Name = 'DESCUENTO'
DataType = datFloat
end
item
Name = 'IMPORTE_TOTAL'
DataType = datCurrency
end
item
Name = 'VISIBLE'
DataType = datSmallInt
end>
ReadOnly = True
end>
JoinDataTables = <>
UnionDataTables = <>
Commands = <>
RelationShips = <>
UpdateRules = <>
Version = 0
Left = 48
Top = 16
end
object DataDictionary: TDADataDictionary
Fields = <>
Left = 46
Top = 142
end
object DABin2DataStreamer: TDABin2DataStreamer
Left = 48
Top = 80
end
object tbl_Cabecera: TDAMemDataTable
RemoteUpdatesOptions = []
Fields = <
item
Name = 'ID'
DataType = datInteger
Required = True
InPrimaryKey = True
end
item
Name = 'ID_EMPRESA'
DataType = datInteger
end
item
Name = 'REFERENCIA'
DataType = datString
Size = 255
end
item
Name = 'TIPO'
DataType = datString
Size = 1
end
item
Name = 'FECHA_FACTURA'
DataType = datDateTime
end
item
Name = 'BASE_IMPONIBLE'
DataType = datCurrency
end
item
Name = 'SITUACION'
DataType = datString
Size = 19
end
item
Name = 'DESCUENTO'
DataType = datFloat
end
item
Name = 'IMPORTE_DESCUENTO'
DataType = datCurrency
end
item
Name = 'IVA'
DataType = datFloat
end
item
Name = 'IMPORTE_IVA'
DataType = datCurrency
end
item
Name = 'RE'
DataType = datFloat
end
item
Name = 'IMPORTE_RE'
DataType = datCurrency
end
item
Name = 'IMPORTE_TOTAL'
DataType = datCurrency
end
item
Name = 'OBSERVACIONES'
DataType = datMemo
end
item
Name = 'NIF_CIF'
DataType = datString
Size = 15
end
item
Name = 'ID_CLIENTE'
DataType = datInteger
end
item
Name = 'NOMBRE'
DataType = datString
Size = 255
end
item
Name = 'CALLE'
DataType = datString
Size = 255
end
item
Name = 'PROVINCIA'
DataType = datString
Size = 255
end
item
Name = 'POBLACION'
DataType = datString
Size = 255
end
item
Name = 'CODIGO_POSTAL'
DataType = datString
Size = 10
end
item
Name = 'RECARGO_EQUIVALENCIA'
DataType = datSmallInt
end
item
Name = 'IMPORTE_NETO'
DataType = datCurrency
end
item
Name = 'IMPORTE_PORTE'
DataType = datCurrency
end
item
Name = 'FORMA_PAGO'
DataType = datString
Size = 255
end>
Params = <
item
Name = 'ID'
Value = ''
ParamType = daptInput
end>
LogChanges = False
StreamingOptions = [soDisableEventsWhileStreaming]
RemoteFetchEnabled = False
LocalSchema = schReport
LocalDataStreamer = DABin2DataStreamer
DetailOptions = [dtCascadeOpenClose, dtCascadeApplyUpdates, dtAutoFetch, dtCascadeDelete, dtCascadeUpdate, dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates, dtIncludeInAllInOneFetch]
MasterOptions = [moCascadeOpenClose, moCascadeApplyUpdates, moCascadeDelete, moCascadeUpdate, moDisableLogOfCascadeDeletes, moDisableLogOfCascadeUpdates]
LogicalName = 'Informe_Cabecera'
IndexDefs = <>
Left = 168
Top = 16
end
object tbl_Detalles: TDAMemDataTable
RemoteUpdatesOptions = []
Fields = <
item
Name = 'ID'
DataType = datInteger
InPrimaryKey = True
end
item
Name = 'ID_FACTURA'
DataType = datInteger
end
item
Name = 'POSICION'
DataType = datInteger
end
item
Name = 'TIPO_DETALLE'
DataType = datString
Size = 10
end
item
Name = 'CONCEPTO'
DataType = datString
Size = 2000
end
item
Name = 'CANTIDAD'
DataType = datInteger
end
item
Name = 'IMPORTE_UNIDAD'
DataType = datCurrency
end
item
Name = 'DESCUENTO'
DataType = datFloat
end
item
Name = 'IMPORTE_TOTAL'
DataType = datCurrency
end
item
Name = 'VISIBLE'
DataType = datSmallInt
end>
Params = <
item
Name = 'ID_FACTURA'
Value = ''
ParamType = daptInput
end>
MasterParamsMappings.Strings = (
'ID_PRESUPUESTO=ID_PRESUPUESTO')
LogChanges = False
StreamingOptions = [soDisableEventsWhileStreaming]
RemoteFetchEnabled = False
LocalSchema = schReport
LocalDataStreamer = DABin2DataStreamer
DetailOptions = [dtCascadeOpenClose, dtCascadeApplyUpdates, dtAutoFetch, dtCascadeDelete, dtCascadeUpdate, dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates, dtIncludeInAllInOneFetch]
MasterOptions = [moCascadeOpenClose, moCascadeApplyUpdates, moCascadeDelete, moCascadeUpdate, moDisableLogOfCascadeDeletes, moDisableLogOfCascadeUpdates]
LogicalName = 'Informe_Detalles'
IndexDefs = <>
Left = 264
Top = 16
end
object tbl_Empresa: TDAMemDataTable
RemoteUpdatesOptions = []
Fields = <>
Params = <
item
Name = 'ID'
Value = '31'
ParamType = daptInput
end>
LogChanges = False
StreamingOptions = [soDisableEventsWhileStreaming]
RemoteFetchEnabled = False
DetailOptions = [dtCascadeOpenClose, dtCascadeApplyUpdates, dtAutoFetch, dtCascadeDelete, dtCascadeUpdate, dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates, dtIncludeInAllInOneFetch]
MasterOptions = [moCascadeOpenClose, moCascadeApplyUpdates, moCascadeDelete, moCascadeUpdate, moDisableLogOfCascadeDeletes, moDisableLogOfCascadeUpdates]
LogicalName = 'Empresa'
IndexDefs = <>
Left = 168
Top = 80
end
end

View File

@ -0,0 +1,358 @@
unit uRptWordFacturaCliente;
interface
uses
SysUtils, Classes, AHWord97, IB, IBCustomDataSet, IBDatabase,
Word2000,
uDAInterfaces, uDADataStreamer, uDABin2DataStreamer, uDAClasses,
uDAScriptingProvider, uDADataTable, uDAMemDataTable;
type
TRptWordFacturaCliente = class(TDataModule)
DABin2DataStreamer: TDABin2DataStreamer;
tbl_Cabecera: TDAMemDataTable;
tbl_Detalles: TDAMemDataTable;
tbl_Empresa: TDAMemDataTable;
schReport: TDASchema;
DataDictionary: TDADataDictionary;
procedure DataModuleCreate(Sender: TObject);
private
FConnection: IDAConnection;
FPlantilla : string;
FWordApp : TWordApp;
FDocumento : TWordDoc;
FNumCapitulos : Integer;
FCodigoFactura : string;
FNombreFichero : String;
function DarNumCapitulos : Integer;
procedure InsertarConceptos(Tabla : Table);
function Generar : Boolean;
function RellenarCabecera : boolean; virtual;
function RellenarInforme : boolean; virtual;
procedure _GenerarFactura(const AID: String);
public
function Exportar(Codigo, Fichero : String): Boolean;
constructor Create (AOwner : TComponent); override;
destructor Destroy; override;
end;
implementation
{ TRptWordFacturaCliente }
{$R *.dfm}
uses
Windows, Variants, Dialogs, uDataModuleServer, uStringsUtils, uSistemaFunc,
srvEmpresas_Impl, uROTypes, uROClasses;
const
rptInforme = 'AlbaranCliente.rdx';
constructor TRptWordFacturaCliente.Create(AOwner: TComponent);
begin
inherited;
FDocumento := NIL;
FPlantilla := DarRutaInformes + rptInforme;
end;
function TRptWordFacturaCliente.DarNumCapitulos: Integer;
var
AuxNumCapitulos : integer;
begin
AuxNumCapitulos := 0;
tbl_Cabecera.First;
while not tbl_Cabecera.Eof do
begin
if tbl_Cabecera.FieldByName('TIPO_DETALLE').AsString = 'Titulo' then
AuxNumCapitulos := AuxNumCapitulos + 1;
tbl_Cabecera.Next;
end;
tbl_Cabecera.First;
Result := AuxNumCapitulos;
end;
destructor TRptWordFacturaCliente.Destroy;
begin
if FDocumento <> NIL then
FDocumento.Free;
FDocumento := NIL;
inherited;
end;
function TRptWordFacturaCliente.Exportar(Codigo, Fichero: String): Boolean;
begin
if EsCadenaVacia(Fichero) then
begin
Result := False;
raise Exception.Create('Falta indicar el fichero donde se exportará el listado.');
end;
FNombreFichero := Fichero;
FCodigoFactura := Codigo;
_GenerarFactura(Codigo);
Result := True;
end;
procedure TRptWordFacturaCliente.DataModuleCreate(Sender: TObject);
begin
schReport.ConnectionManager := dmServer.ConnectionManager;
FConnection := dmServer.DarNuevaConexion;
end;
function TRptWordFacturaCliente.Generar : Boolean;
var
Aux : OleVariant;
begin
FWordApp := TWordApp.Create (False, False);
with FWordApp do
begin
Visible := False;
ScreenUpdating := False;
end;
FDocumento := TWordDoc.CreateNewDoc(FWordApp, FPlantilla);
FWordApp.ScreenUpdating := False;
try
if not RellenarCabecera then
RaiseError('Se producido un error al generar la cabecera en MS Word.');
if not RellenarInforme then
RaiseError('Se producido un error al generar el informe en MS Word.');
FDocumento.SaveAs(FNombreFichero);
FWordApp.CloseApp(wdDoNotSaveChanges);
Result := True;
finally
FDocumento := NIL;
FWordApp := NIL;
end;
end;
procedure TRptWordFacturaCliente.InsertarConceptos(Tabla : Table);
var
numRows, numCols, mergeSplit, shiftCells : OleVariant;
iContador : Integer;
TotalConceptos : Double;
begin
numRows := 2;
numCols := 1;
mergeSplit := False;
shiftCells := False;
iContador := 2; // Empezar en la 2ª fila de celdas. La primera es la
// cabecera de la tabla.
with Tabla, tbl_Detalles do
begin
while not EOF do
begin
if FieldByName('TIPO_DETALLE').AsString <> 'Concepto' then
Break;
// Partir la celda actual en 2 filas de 1 columna.
Rows.Item(iContador).Cells.Split (numRows, numCols, mergesplit);
Cell(iContador, 1).Range.Text := FieldByName('CONCEPTO').AsString;
Cell(iContador, 2).Range.Text := FieldByName('CANTIDAD').AsString;
Cell(iContador, 3).Range.Text := FormatFloat(DISPLAY_EUROS2, FieldByName('IMPORTE_UNIDAD').AsFloat);
Cell(iContador, 4).Range.Text := FormatFloat(DISPLAY_EUROS2, FieldByName('IMPORTE_TOTAL').AsFloat);
TotalConceptos := TotalConceptos + FieldByName('IMPORTE_TOTAL').AsFloat;
Next;
Inc (iContador);
end;
// Borrar la fila vacía que sobra
Rows.Item(iContador).Cells.Delete(shiftCells);
Cell(iContador, 1).Range.Text := 'Total: ' + FormatFloat(DISPLAY_EUROS2, TotalConceptos);
AutoFitBehavior(wdAutoFitWindow);
end;
end;
function TRptWordFacturaCliente.RellenarCabecera: boolean;
var
NombreFichero,
Texto,
FicheroTemporal : String;
LinkToFile, SaveWithDocument, _Range : OleVariant;
Imagen : InlineShape;
_ShiftCells : OleVariant;
begin
//PARA DIBUJAR EL LOGOTIPO MULTIEMPRESA
{--------------------------- PENDIENTE
if (EmpresaActiva.Logotipo <> Nil) then
begin
//Activamos cabecera
FWordApp.Application.ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader;
LinkToFile := False;
SaveWithDocument := True;
_Range := EmptyParam;
FicheroTemporal := DarFicheroTemporal;
EmpresaActiva.Logotipo.SaveToFile (FicheroTemporal);
Imagen := FWordApp.Application.ActiveWindow.ActivePane.Selection.InlineShapes.AddPicture(ficherotemporal, LinkToFile, SaveWithDocument, _Range);
//Formateamos imagen
if ((Imagen.Get_Width > ANCHO_LOGO_INF)) then
begin
Imagen.Set_Height(((ANCHO_LOGO_INF * Imagen.Get_Height) /Imagen.Get_Width));
Imagen.Set_Width(ANCHO_LOGO_INF);
end;
end;
---------------------------- }
with FDocumento, tbl_Cabecera do
begin
ReplaceBookmark('CodigoFacturaCab', FCodigoFactura);
ReplaceBookmark('FechaFacturaCab', FieldByName('FECHA_FACTURA').AsString);
ReplaceBookmark('VencimientoCab', ''{FieldByName('FECHAVENCIMIENTO').AsString});
ReplaceBookmark('FormaPagoCab', FieldByName('FORMA_PAGO').AsString);
ReplaceBookmark('BancoCab', ''{FieldByName('BANCO').AsString});
ReplaceBookmark('NombreClienteCab', FieldByName('NOMBRE').AsString);
ReplaceBookmark('CIFClienteCab', FieldByName('NIF_CIF').AsString);
ReplaceBookmark('DireccionClienteCab', FieldByName('CALLE').AsString);
ReplaceBookmark('PoblacionClienteCab',
FieldByName('CODIGO_POSTAL').AsString + ' ' +
FieldByName('POBLACION').AsString + ' ' + FieldByName('PROVINCIA').AsString);
ReplaceBookmark('BaseImponible', FormatFloat(DISPLAY_EUROS2, FieldByName('BASE_IMPONIBLE').AsFloat));
// ???????? ReplaceBookmark('BaseImponible2', FormatFloat(DISPLAY_EUROS2, FieldByName('BASE_IMPONIBLE2').AsFloat);
if (FieldByName('DESCUENTO').AsInteger = 0) then
begin
ReplaceBookmark('BaseImponibleTexto', 'Base imponible');
FWordApp.GotoBookmark('CeldasDescuento');
_ShiftCells := wdDeleteCellsShiftLeft;
FWordApp.Application.Selection.Cells.Delete(_ShiftCells);
end
else begin
ReplaceBookmark('Descuento', FieldByName('DESCUENTO').AsString);
ReplaceBookmark('ImporteDto', FormatFloat(DISPLAY_EUROS2, FieldByName('IMPORTE_DESCUENTO').AsFloat));
end;
if EsCadenaVacia(FieldByName('IVA').AsString) then
ReplaceBookmark('IVA', '0')
else
ReplaceBookmark('IVA', FieldByName('IVA').AsString);
ReplaceBookmark('ImporteIVA', FormatFloat(DISPLAY_EUROS2, FieldByName('IMPORTE_IVA').AsFloat));
ReplaceBookmark('ImporteTotal', FormatFloat(DISPLAY_EUROS2, FieldByName('IMPORTE_TOTAL').AsFloat));
Texto := FieldByName('OBSERVACIONES').AsString;
if not EsCadenaVacia(Texto) then
begin
NombreFichero := DarFicheroTemporal;
EscribirEnFichero(NombreFichero, Texto);
FWordApp.InsertFile(NombreFichero, 'Descripcion');
SysUtils.DeleteFile(NombreFichero);
end;
ReplaceBookmark('NombreEmpresa', tbl_Empresa.FieldByName('NOMBRE').AsString);
ReplaceBookmark('CifEmpresa', tbl_Empresa.FieldByName('NIF_CIF').AsString);
ReplaceBookmark('DireccionEmpresa',
Format('%s. %s %s', [tbl_Empresa.FieldByName('CALLE').AsString,
tbl_Empresa.FieldByName('CODIGO_POSTAL').AsString, tbl_Empresa.FieldByName('POBLACION').AsString]));
ReplaceBookmark('TelefonoEmpresa', tbl_Empresa.FieldByName('TELEFONO_1').AsString);
ReplaceBookmark('FaxEmpresa', tbl_Empresa.FieldByName('FAX').AsString);
ReplaceBookmark('CorreoEmpresa', tbl_Empresa.FieldByName('EMAIL_1').AsString);
ReplaceBookmark('DatosRegistroMercantil', tbl_Empresa.FieldByName('REGISTRO_MERCANTIL').AsString);
Close;
end;
Result := True;
end;
function TRptWordFacturaCliente.RellenarInforme : boolean;
var
numRows, numCols, mergesplit : OleVariant;
iRowCount : Integer;
TipoConAnterior : String;
Seleccion : TWordRange;
TotalCapitulo : Double;
EsCapitulo : Boolean;
begin
Result := False;
iRowCount := 2;
numrows := 2;
numcols := 1;
mergeSplit := False;
TipoConAnterior := '';
TotalCapitulo := 0;
EsCapitulo := False;
with FDocumento.Document.Tables.Item(1), tbl_detalles do
begin
First;
while not tbl_detalles.EOF do
begin
if (TipoConAnterior = 'Concepto') and (FieldByName('TIPO_DETALLE').AsString = 'Titulo') then
begin
Rows.Item (iRowCount).Cells.Split (numRows, numCols, mergesplit);
if EsCapitulo then
begin
Rows.Item (iRowCount).Cells.Split (numRows, numCols, mergesplit);
Cell(iRowCount, 2).Range.Text := 'TOTAL DEL CAPÍTULO';
Cell(iRowCount, 5).Range.Text := FormatFloat(DISPLAY_EUROS2, TotalCapitulo);
TotalCapitulo := 0;
Inc (iRowCount);
end;
Inc (iRowCount);
end;
Rows.Item (iRowCount).Cells.Split (numRows, numCols, mergesplit);
if FieldByName('TIPO_DETALLE').AsString = 'Titulo' then
begin
Cell(iRowCount, 2).Range.Text := FieldByName('CONCEPTO').AsString;
Rows.Item(iRowCount).Select;
Seleccion := FDocumento.AddRangeFromSelection;
Seleccion.Bold := True;
TotalCapitulo := 0;
EsCapitulo := True;
end
else begin
Cell(iRowCount, 1).Range.Text := FieldByName('REFERENCIA').AsString;
Cell(iRowCount, 2).Range.Text := FieldByName('CONCEPTO').AsString;
Cell(iRowCount, 3).Range.Text := FieldByName('CANTIDAD').AsString; { + ' ' +
FieldByName('UNIDADESMEDIDA').AsString;}
Cell(iRowCount, 4).Range.Text := FormatFloat(DISPLAY_EUROS2, FieldByName('IMPORTE_UNIDAD').AsFloat);
Cell(iRowCount, 5).Range.Text := FormatFloat(DISPLAY_EUROS2, FieldByName('IMPORTE_TOTAL').AsFloat);
TotalCapitulo := TotalCapitulo + FieldByName('IMPORTE_TOTAL').AsFloat;
end;
TipoConAnterior := FieldByName('TIPO_DETALLE').AsString;
Next;
Inc (iRowCount);
end;
if EsCapitulo then
begin
Rows.Item (iRowCount).Cells.Split (numRows, numCols, mergesplit);
Cell(iRowCount, 2).Range.Text := 'TOTAL DEL CAPÍTULO';
Cell(iRowCount, 5).Range.Text := FormatFloat(DISPLAY_EUROS2, TotalCapitulo);
TotalCapitulo := 0;
end;
Close;
end;
Result := True;
end;
procedure TRptWordFacturaCliente._GenerarFactura(const AID: String);
var
ACopiaPlantilla : String;
begin
tbl_Cabecera.ParamByName('ID').AsString := AID;
tbl_Detalles.ParamByName('ID_FACTURA').AsString := AID;
tbl_Cabecera.Active := True;
tbl_Detalles.Active := True;
FCodigoFactura := AID;
ACopiaPlantilla := DarFicheroTemporal;
CopiarFichero(FPlantilla, ACopiaPlantilla);
FPlantilla := ACopiaPlantilla;
try
if RecuperarEmpresa(tbl_Cabecera.FieldByName('ID_EMPRESA').AsInteger, tbl_Empresa) then
Generar;
finally
SysUtils.DeleteFile(ACopiaPlantilla);
end;
end;
end.

View File

@ -36,17 +36,18 @@ type
protected
{ IsrvFacturasCliente methods }
function GenerateReport(const FacturaID: String): Binary;
function GenerateReportEnWord(const ID: Integer): Binary;
end;
implementation
{$R *.dfm}
uses
{Generated:} FactuGES_Invk, Dialogs,
{Generated:} FactuGES_Invk, Dialogs, uSistemaFunc,
uDataModuleServer, uDatabaseUtils, uUsersManager, schFacturasClienteClient_Intf,
uRestriccionesUsuarioUtils,
// uRptFacturasCliente_Server,
uBizFacturasClienteServer;
uBizFacturasClienteServer, uRptWordFacturaCliente;
procedure Create_srvFacturasCliente(out anInstance : IUnknown);
begin
@ -95,6 +96,26 @@ begin
}
end;
function TsrvFacturasCliente.GenerateReportEnWord(const ID: Integer): Binary;
var
AReportGenerator : TRptWordFacturaCliente;
AFicheroTMP : TFileName;
begin
Result := NIL;
AFicheroTMP := DarFicheroTemporal;
AReportGenerator := TRptWordFacturaCliente.Create(nil);
try
if AReportGenerator.Exportar(IntToStr(ID), AFicheroTMP) then
begin
Result := Binary.Create;
Result.LoadFromFile(AFicheroTMP);
SysUtils.DeleteFile(AFicheroTMP)
end;
finally
FreeAndNIL(AReportGenerator);
end;
end;
initialization
TROClassFactory.Create('srvFacturasCliente', Create_srvFacturasCliente, TsrvFacturasCliente_Invoker);

View File

@ -242,6 +242,14 @@
</Parameter>
</Parameters>
</Operation>
<Operation Name="GenerateReportEnWord" UID="{04A25AE7-9AC6-474F-9A4A-04D8292959E6}">
<Parameters>
<Parameter Name="Result" DataType="Binary" Flag="Result">
</Parameter>
<Parameter Name="ID" DataType="Integer" Flag="In" >
</Parameter>
</Parameters>
</Operation>
</Operations>
</Interface>
</Interfaces>

View File

@ -453,6 +453,7 @@ type
IsrvFacturasCliente = interface(IDataAbstractService)
['{56B4FFF0-AB1B-46B2-BA16-ABD5360F6311}']
function GenerateReport(const FacturaID: String): Binary;
function GenerateReportEnWord(const ID: Integer): Binary;
end;
{ CosrvFacturasCliente }
@ -466,6 +467,7 @@ type
function __GetInterfaceName:string; override;
function GenerateReport(const FacturaID: String): Binary;
function GenerateReportEnWord(const ID: Integer): Binary;
end;
{ IsrvFacturasProveedor }
@ -1317,6 +1319,23 @@ begin
end
end;
function TsrvFacturasCliente_Proxy.GenerateReportEnWord(const ID: Integer): Binary;
begin
try
result := nil;
__Message.InitializeRequestMessage(__TransportChannel, 'FactuGES', __InterfaceName, 'GenerateReportEnWord');
__Message.Write('ID', TypeInfo(Integer), ID, []);
__Message.Finalize;
__TransportChannel.Dispatch(__Message);
__Message.Read('Result', TypeInfo(Binary), result, []);
finally
__Message.UnsetAttributes(__TransportChannel);
__Message.FreeStream;
end
end;
{ CosrvFacturasProveedor }
class function CosrvFacturasProveedor.Create(const aMessage: IROMessage; aTransportChannel: IROTransportChannel): IsrvFacturasProveedor;

View File

@ -133,6 +133,7 @@ type
protected
published
procedure Invoke_GenerateReport(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions);
procedure Invoke_GenerateReportEnWord(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions);
end;
TsrvFacturasProveedor_Invoker = class(TDataAbstractService_Invoker)
@ -522,6 +523,34 @@ begin
end;
end;
procedure TsrvFacturasCliente_Invoker.Invoke_GenerateReportEnWord(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions);
{ function GenerateReportEnWord(const ID: Integer): Binary; }
var
ID: Integer;
lResult: Binary;
__lObjectDisposer: TROObjectDisposer;
begin
lResult := nil;
try
__Message.Read('ID', TypeInfo(Integer), ID, []);
lResult := (__Instance as IsrvFacturasCliente).GenerateReportEnWord(ID);
__Message.InitializeResponseMessage(__Transport, 'FactuGES', 'srvFacturasCliente', 'GenerateReportEnWordResponse');
__Message.Write('Result', TypeInfo(Binary), lResult, []);
__Message.Finalize;
__Message.UnsetAttributes(__Transport);
finally
__lObjectDisposer := TROObjectDisposer.Create(__Instance);
try
__lObjectDisposer.Add(lResult);
finally
__lObjectDisposer.Free();
end;
end;
end;
{ TsrvFacturasProveedor_Invoker }
procedure TsrvFacturasProveedor_Invoker.Invoke_GenerateReport(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions);

Binary file not shown.

View File

@ -112,7 +112,8 @@ uses
schReferenciasServer_Intf in '..\Modulos\Referencias\Model\schReferenciasServer_Intf.pas',
schReferenciasClient_Intf in '..\Modulos\Referencias\Model\schReferenciasClient_Intf.pas',
uRptFichasEmpleado_Server in '..\Modulos\Contactos\Reports\uRptFichasEmpleado_Server.pas' {RptFichasEmpleado: TDataModule},
uRptEtiquetasContacto_Server in '..\Modulos\Contactos\Reports\uRptEtiquetasContacto_Server.pas' {RptEtiquetasContacto: TDataModule};
uRptEtiquetasContacto_Server in '..\Modulos\Contactos\Reports\uRptEtiquetasContacto_Server.pas' {RptEtiquetasContacto: TDataModule},
uRptWordFacturaCliente in '..\Modulos\Facturas de cliente\Reports\uRptWordFacturaCliente.pas' {RptWordFacturaCliente: TDataModule};
{$R *.res}
{$R ..\Servicios\RODLFile.res}

View File

@ -36,6 +36,12 @@
<Borland.ProjectType />
<BorlandProject>
<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">3082</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion"></VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys><VersionInfoKeys Name="CompileDate"></VersionInfoKeys></VersionInfoKeys><Excluded_Packages>
<Excluded_Packages Name="C:\Documents and Settings\All Users\Documentos\RAD Studio\5.0\Bpl\dxPSCoreD10.bpl">ExpressPrinting System by Developer Express Inc.</Excluded_Packages>
<Excluded_Packages Name="$(BDS)\bin\dcloffice2k100.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDS)\bin\dclofficexp100.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
@ -114,6 +120,10 @@
<Form>RptFacturasCliente</Form>
<DesignClass>TDataModule</DesignClass>
</DCCReference>
<DCCReference Include="..\Modulos\Facturas de cliente\Reports\uRptWordFacturaCliente.pas">
<Form>RptWordFacturaCliente</Form>
<DesignClass>TDataModule</DesignClass>
</DCCReference>
<DCCReference Include="..\Modulos\Facturas de cliente\Servidor\srvFacturasCliente_Impl.pas">
<Form>srvFacturasCliente</Form>
<DesignClass>TDataAbstractService</DesignClass>

View File

@ -4,7 +4,6 @@
</PropertyGroup>
<ItemGroup />
<ItemGroup>
<Projects Include="C:\Archivos de programa\RemObjects Software\RemObjects SDK for Delphi\Samples\Named Pipes\NamedPipeServer.dproj" />
<Projects Include="FactuGES_Server.dproj" />
</ItemGroup>
<ProjectExtensions>
@ -22,23 +21,14 @@
<Target Name="FactuGES_Server:Make">
<MSBuild Projects="FactuGES_Server.dproj" Targets="Make" />
</Target>
<Target Name="NamedPipeServer">
<MSBuild Projects="C:\Archivos de programa\RemObjects Software\RemObjects SDK for Delphi\Samples\Named Pipes\NamedPipeServer.dproj" Targets="" />
</Target>
<Target Name="NamedPipeServer:Clean">
<MSBuild Projects="C:\Archivos de programa\RemObjects Software\RemObjects SDK for Delphi\Samples\Named Pipes\NamedPipeServer.dproj" Targets="Clean" />
</Target>
<Target Name="NamedPipeServer:Make">
<MSBuild Projects="C:\Archivos de programa\RemObjects Software\RemObjects SDK for Delphi\Samples\Named Pipes\NamedPipeServer.dproj" Targets="Make" />
</Target>
<Target Name="Build">
<CallTarget Targets="FactuGES_Server;NamedPipeServer" />
<CallTarget Targets="FactuGES_Server" />
</Target>
<Target Name="Clean">
<CallTarget Targets="FactuGES_Server:Clean;NamedPipeServer:Clean" />
<CallTarget Targets="FactuGES_Server:Clean" />
</Target>
<Target Name="Make">
<CallTarget Targets="FactuGES_Server:Make;NamedPipeServer:Make" />
<CallTarget Targets="FactuGES_Server:Make" />
</Target>
<Import Condition="Exists('$(MSBuildBinPath)\Borland.Group.Targets')" Project="$(MSBuildBinPath)\Borland.Group.Targets" />
</Project>