Ver Mensaje Individual
  #12  
Antiguo 18-11-2025
Avatar de ramherfer
ramherfer ramherfer is offline
Miembro
 
Registrado: may 2013
Ubicación: Valencia
Posts: 162
Reputación: 14
ramherfer Va por buen camino
Cita:
Empezado por seccion_31 Ver Mensaje
le doy un vistazo

pero pasame el codigo de tu programa que carga el array con los valores para probarlo bien.

Saludos !
Claro sin problemas:

Código Delphi [-]
        while not QFrasIva.Eof do
        begin

            dTotalIva := QFrasIva.FieldByName('IMPORTE_IVA').AsFloat +
                         QFrasIva.FieldByName('IMPORTE_RECARGO').AsFloat;

            // Añadir IVA si hay base imponible o si la cuota total es 0
            if QFrasIva.FieldByName('BASE_IMPONIBLE').AsFloat <> 0 then begin

                  // Caso: motivo exencion
                  // (N2: no sujeta por reglas de localización, salvo que exista motivo de exención)
                  if dTotalIva = 0 then begin

                        if QFrasIva.FieldByName('MOTIVO_EXENCION').AsString <> '' then begin

                            sMotivoExencion    := QFrasIva.FieldByName('MOTIVO_EXENCION').AsString;
                            sCalificaOperacion := '';

                        end else begin

                            sMotivoExencion    := '';
                            sCalificaOperacion := 'N2'; // NO SUJETA POR REGLAS DE LOCALIZACIÓN

                        end;

                        actual.exenta[index].tipoExenta            := sMotivoExencion;
                        actual.exenta[index].claveRegimen          := QRegSif.FieldByName('AEAT_CLAVE_REGIMEN').AsString;
                        actual.exenta[index].calificacionOperacion := sCalificaOperacion;
                        actual.exenta[index].baseImp               := value(QFrasIva.FieldByName('BASE_IMPONIBLE').AsString);

                        Inc(actual.nexentas);
                  end
                  // Caso: con IVA (total distinto de 0) y no exento
                  else if dTotalIva <> 0 then begin

                        // Asignar valores al array de IVA
                        actual.iva[index].baseImp := value(QFrasIva.FieldByName('BASE_IMPONIBLE').AsString);
                        actual.iva[index].iva     := value(QFrasIva.FieldByName('PORCENTAJE_IVA').AsString);
                        actual.iva[index].impiva  := value(QFrasIva.FieldByName('IMPORTE_IVA').AsString);

                        if QFrasIva.FieldByName('IMPORTE_RECARGO').AsFloat <> 0 then
                        begin
                          actual.iva[index].req    := value(QFrasIva.FieldByName('PORCENTAJE_RECARGO').AsString);
                          actual.iva[index].impreq := value(QFrasIva.FieldByName('IMPORTE_RECARGO').AsString);
                        end
                        else
                        begin
                          actual.iva[index].req    := value('0');
                          actual.iva[index].impreq := value('0');
                        end;

                        cuota := cuota + dTotalIva;

                        Inc(actual.nivas);

                  end;

            end;

            Inc(index);
            QFrasIva.Next;

        end; // while registros de IVA

Gracias.
Un saludo,
Ramiro
__________________
Se humilde para admitir tus errores, inteligente para aprender de ellos y maduro para corregirlos.
Responder Con Cita