Ver Mensaje Individual
  #3500  
Antiguo 11-11-2022
APO APO is offline
Miembro
 
Registrado: feb 2008
Posts: 121
Reputación: 17
APO Va por buen camino
Cita:
Empezado por sexxxwax Ver Mensaje
Buenas a tod@s, estoy migrando un programa de D6 a D10 con todo lo que supone d incompatibilidades (componentes bde, informes qr, ...) y ahora encima esto del ticketbai; estoy leyendo el foro d ticketbai (voy x la página 60) y me imagino las horas y roturas d cabeza que llevais, la cantidad d errores que habeis solucionado entre todos, así que os felicito.

Yo necesitaría algo d ayuda, así que pondré varias cosas x si alguno tiene tiempo o ganas d ayudarme, d todas formas gracias x anticipado.

Estoy montando el xml insertando datos d las tablas del tpv y al hacer el bucle para recorrer las líneas d la venta actual añadiendolas como iddetalleventa sólo me carga la última línea. Os pego el código x si me podeis ayudar.

Código Delphi [-]
DATOSFACTURA.FechaOperacion:=TPVH.FIELDBYNAME('FECHA').ASSTRING; 
DATOSFACTURA.DescripcionFactura:='TPV1-'+FIELDBYNAME('N_VENTA').ASSTRING; 
TPV.FIRST; 
while NOT TPV.EOF do BEGIN 
    with DATOSFACTURA.DetallesFactura.IDDetalleFactura do begin 
        DescripcionDetalle:=FIELDBYNAME('ARTICULO').ASSTRING; 
        Cantidad:=FIELDBYNAME('CTDAD').ASSTRING; 
        ImporteUnitario:=FLOATTOSTR(ROUNDTO(FIELDBYNAME('PVP_E U').VALUE,-2)); 
        Descuento:=FIELDBYNAME('DTO').ASSTRING; 
        ImporteTotal:=FLOATTOSTR(ROUNDTO(FIELDBYNAME('IMPORTE_ EU').VALUE,-2)); 
    end; 
    TPV.NEXT; 
END; 
DATOSFACTURA.IMPORTETOTALFACTURA:=FLOATTOSTR(ROUNDTO(TPVH.FIELDBYNAME('TOTAL_EU').VALUE,-2));

Yo lo hago de la siguiente manera:

Código Delphi [-]
var
   FicheroXML: IXMLTicketBai;

...

            with FicheroXML.Factura.DatosFactura do
            begin
               FechaOperacion:=FormatDateTime('dd-mm-yyyy',qExec.FieldByName('FECHA').AsDateTime);
               DescripcionFactura:='VENTAS AL POR MENOR EESS';
               //Detalle factura
               qExec.First;
               i:=0;
               while not qExec.Eof do
               begin
                  DetallesFactura.Add;
                  DetallesFactura.IDDetalleFactura[i].DescripcionDetalle:=trim(qExec.FieldByName('DESCRIPCION_PRODUCTO').AsString);
                  DetallesFactura.IDDetalleFactura[i].Cantidad:=TransFloat(qExec.FieldByName('UNIDADES').AsFloat,2);
                  DetallesFactura.IDDetalleFactura[i].ImporteUnitario:=TransFloat(qExec.FieldByName('PRECIO_VENTA').AsFloat,8); //Importe unitario SIN  IVA
                  if Redondeo(qExec.FieldByName('PRECIO_VENTA').AsFloat,2)<>Redondeo(qExec.FieldByName('PRECIO').AsFloat,  2) then
                  begin
                     //Importe en euros del descuento de la línea de factura (el importe de descuento ha de ir siempre en positivo).
                     DetallesFactura.IDDetalleFactura[i].Descuento:=TransFloat((qExec.FieldByName('PRECIO_VENTA').AsFloat-qExec.FieldByName('PRECIO').AsFloat) *
                                                                                Redondeo(qExec.FieldByName('UNIDADES').AsFloat,2),2);
                  end
                  else
                  begin
                     DetallesFactura.IDDetalleFactura[i].Descuento:='0.00';
                  end;
                  DetallesFactura.IDDetalleFactura[i].ImporteTotal:=TransFloat(qExec.FieldByName('IMPORTE_IVA').AsFloat,2); //Importe total CON IVA
                  qExec.Next;
                  i:=i+1;
               end;
               ImporteTotalFactura:=TransFloat(qExec.FieldByName('TOTAL').AsFloat,2); //Importe total de la factura simplificada
               //Claves
               Claves.Add;
               Claves.IDClave[0].ClaveRegimenIvaOpTrascendencia:='01'; //Operación de régimen general
            end;
Responder Con Cita