Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 24-08-2011
novato_erick novato_erick is offline
Miembro
 
Registrado: ago 2010
Ubicación: Panamá
Posts: 396
Poder: 14
novato_erick Va por buen camino
campos calculados para presentar precio de ventas

Hola nuevamente a todos:

He creado un procedimiento que calcula precio de ventas con su respectivo impuesto de un articulo a partir de un precio de compra

los componente que utilizo es un TComboBox llamado: cbxCalculoBase con dos items Precio de compra (si esta elegida esta opción realiza calculos respecto al precio de compra)y en el items Manual (simplemente no realiza calculo y permite agregar los precios que el usuario desee al articulo).

Creo que me di a explicar.

Siguiendo:

Cree un procedimiento de esta manera:

Código Delphi [-]
procedure TFrmArticulos.CalculaTotalesPrecios;
var
  i: Integer;
begin
  // Calcula los totales de los precios de venta referente a la compra
  pc := 0.00; // Precio de compra
  pg := 0.00; // Precio de Gasto
  pu := 0.00; // Precio con Utilidad
  pva := 0.00; // Precio con Impuesto
  pf := 0.00; // Precio Fijo
  // ****************
  psinitbm := 0.00; // Precio sin IVA
  pconitbm := 0.00; // Precio con IVA
  porcentajeG := 0.00; // Porcenjate de Gasto
  porcentajeU := 0.00; // orcentaje de Utilidad
  porcentajeV := 0.00; // Porcentaje de Varios
  // ***************************
  Gasto := 0.00; // Gasto
  varios := 0.00; // Varios otros valores
  utilidad := 0.00; // utilidad del producto
  subtotalg := 0.00; // subtototal de gastos
  subtotalv := 0.00; // subtotal varios
  subtotalu := 0.00; // subtotal  utilidad
  // ***********************
  Gasto2 := 0.00;
  varios2 := 0.00;
  utilidad2 := 0.00;
  subtotalg2 := 0.00;
  subtotalv2 := 0.00;
  subtotalu2 := 0.00;
  psinitbm2 := 0.00;
  pconitbm2 := 0.00;
  porcentajeG2 := 0.00;
  porcentajeU2 := 0.00;
  porcentajeV2 := 0.00;
  // ***************************
  Gasto3 := 0.00;
  varios3 := 0.00;
  utilidad3 := 0.00;
  subtotalg3 := 0.00;
  subtotalv3 := 0.00;
  subtotalu3 := 0.00;
  tempPrecio := 0.00;

  begin

    begin
       pc := StrToFloat(frmArticulos.dbePCompra.Text);
       psinitbm:= pc;
    end;

    frmArticulos.dbePSinIV.Text := FloatToStr(psinitbm);
    varios := StrToFloat(frmArticulos.txtVarios.Text);
    Gasto := StrToFloat(frmArticulos.txtGastos.Text);
    utilidad := StrToFloat(frmArticulos.txtUtilidad.Text);
    if dbeImpuesto.Text > '0' then
    begin
      impuesto := strtoint(dbeImpuesto.Text);
    end;
    // *****************************************
    pc := StrToFloat(frmArticulos.dbePCompra.Text);
    psinitbm2 := pc;
    frmArticulos.dbePSinIV2.Text := FloatToStr(psinitbm2);
    varios2 := StrToFloat(frmArticulos.txtVarios2.Text);
    Gasto2 := StrToFloat(frmArticulos.txtGastos2.Text);
    utilidad2 := StrToFloat(frmArticulos.txtUtilidad2.Text);

    // ************************************************
    pc := StrToFloat(frmArticulos.dbePCompra.Text);
    psinitbm3 := pc;
    frmArticulos.dbePSinIV3.Text := FloatToStr(psinitbm3);
    varios3 := StrToFloat(frmArticulos.txtVarios3.Text);
    Gasto3 := StrToFloat(frmArticulos.txtGastos3.Text);
    utilidad3 := StrToFloat(frmArticulos.txtUtilidad3.Text);
    // ***************************************************
    begin
      if Gasto > 0 then
      begin
        porcentajeG := (psinitbm * Gasto / 100);
        psinitbm := Roundto(pc + porcentajeG, -2);
        if dbeImpuesto.Text > '0' then
        begin
          porcentajeImpuestoG := (psinitbm * impuesto / 100);
          dbePConIV.Text :=
            FloatToStr(Roundto(psinitbm + porcentajeImpuestoG, -2));
        end;
      end;
      // *************************
      if Gasto2 > 0 then
      begin
        porcentajeG2 := (psinitbm2 * Gasto2 / 100);
        psinitbm2 := Roundto(pc + porcentajeG2, -2);
        if dbeImpuesto.Text > '0' then
        begin
          porcentajeImpuestoG2 := (psinitbm2 * impuesto / 100);
          dbePConIV2.Text :=
            FloatToStr(Roundto(psinitbm2 + porcentajeImpuestoG2, -2));
        end;
      end;
      // ************************************
      if Gasto3 > 0 then
      begin
        porcentajeG3 := (psinitbm3 * Gasto3 / 100);
        psinitbm3 := Roundto(pc + porcentajeG3, -2);
        if dbeImpuesto.Text > '0' then
        begin
          porcentajeImpuestoG3 := (psinitbm3 * impuesto / 100);
          dbePConIV3.Text :=
            FloatToStr(Roundto(psinitbm3 + porcentajeImpuestoG3, -2));
        end;
      end;
      // *************************************
      if varios > 0 then
      begin
        subtotalv := psinitbm + (psinitbm * varios / 100);
        porcentajeV := subtotalv;
        psinitbm := Roundto(subtotalv, -2);
        if dbeImpuesto.Text > '0' then
        begin
          porcentajeIMpuestoV := (psinitbm * impuesto / 100);
          dbePConIV.Text :=
            FloatToStr(Roundto(psinitbm + porcentajeIMpuestoV, -2));
        end;
      end;
      // ***********************************
      if varios2 > 0 then
      begin
        subtotalv2 := psinitbm2 + (psinitbm2 * varios2 / 100);
        porcentajeV2 := subtotalv2;
        psinitbm2 := Roundto(subtotalv2, -2);
        if dbeImpuesto.Text > '0' then
        begin
          porcentajeIMpuestoV2 := (psinitbm2 * impuesto / 100);
          dbePConIV2.Text :=
            FloatToStr(Roundto(psinitbm2 + porcentajeIMpuestoV2, -2));
        end;
      end;
      // **********************************
      if varios3 > 0 then
      begin
        subtotalv3 := psinitbm3 + (psinitbm3 * varios3 / 100);
        porcentajeV3 := subtotalv3;
        psinitbm3 := Roundto(subtotalv3, -2);
        if dbeImpuesto.Text > '0' then
        begin
          porcentajeIMpuestoV3 := (psinitbm3 * impuesto / 100);
          dbePConIV3.Text :=
            FloatToStr(Roundto(psinitbm3 + porcentajeIMpuestoV3, -2));
        end;
      end;
      // ****************************************
      if utilidad > 0 then
      begin
        subtotalu := psinitbm + (psinitbm * utilidad / 100);
        porcentajeU := subtotalu;
        psinitbm := Roundto(subtotalu, -2);
        if dbeImpuesto.Text > '0' then
        begin
          porcentajeIMpuestoU := (psinitbm * impuesto / 100);
          dbePConIV.Text :=
            FloatToStr(Roundto(psinitbm + porcentajeIMpuestoU, -2));
        end;
      end;
      // ****************************************
      if utilidad2 > 0 then
      begin
        subtotalu2 := psinitbm2 + (psinitbm2 * utilidad2 / 100);
        porcentajeU2 := subtotalu2;
        psinitbm2 := Roundto(subtotalu2, -2);
        if dbeImpuesto.Text > '0' then
        begin
          porcentajeIMpuestoU2 := (psinitbm2 * impuesto / 100);
          dbePConIV2.Text :=
            FloatToStr(Roundto(psinitbm2 + porcentajeIMpuestoU2, -2));
        end;
      end;
      // ****************************************
      if utilidad3 > 0 then
      begin
        subtotalu3 := psinitbm3 + (psinitbm3 * utilidad3 / 100);
        porcentajeU3 := subtotalu3;
        psinitbm3 := Roundto(subtotalu3, -2);
        if dbeImpuesto.Text > '0' then
        begin
          porcentajeIMpuestoU3 := (psinitbm3 * impuesto / 100);
          dbePConIV3.Text :=
            FloatToStr(Roundto(psinitbm3 + porcentajeIMpuestoU3, -2));
        end;

      end;
      // *********************************
    end;
    frmArticulos.dbePSinIV.Text := FloatToStr(psinitbm);
    frmArticulos.dbePSinIV2.Text := FloatToStr(psinitbm2);
    frmArticulos.dbePSinIV3.Text := FloatToStr(psinitbm3);
  end;

end;

En si... hay algunos aspecto que me están provocando error y no he podido resolver aun; Este es cuando al llamar al formulario de FrmArticulo en modo de Edición me envía el siguiente error:
Cita:
---------------------------
Debugger Exception Notification
---------------------------
Project Inventarios.exe raised exception class EAccessViolation with message 'Access violation at address 008D0363 in module 'Inventarios.exe'. Read of address 00000608'.
---------------------------
Break Continue Help
---------------------------
uso del debug y me envia a esta linea del procedimiento:
Código Delphi [-]
// ***************************
  Gasto3 := 0.00;
  varios3 := 0.00;
  utilidad3 := 0.00;
  subtotalg3 := 0.00;
  subtotalv3 := 0.00;
  subtotalu3 := 0.00;
  tempPrecio := 0.00;

begin
       pc := StrToFloat(frmArticulos.dbePCompra.Text);// aquí me envía el debug
       psinitbm:= pc;
end;

justamente después de las ultimas variables con datos
Código Delphi [-]
procedure TFrmArticulos.CalculaTotalesPrecios;

definitivamente hay algo mal pero no he logrado dar con el diagnostico algún terapeuta que me de ayuda?

Saludos

novato_erick

Última edición por novato_erick fecha: 24-08-2011 a las 02:07:05.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Campos Calculados Kaller Tablas planas 1 12-12-2006 00:11:13
campos calculados Nelly SQL 2 07-10-2005 18:13:51
Campos calculados SaurioNet MS SQL Server 4 21-01-2005 23:47:38
Campos CAlculados karlita_cb Tablas planas 4 24-03-2004 04:40:03
Lio Con Los Campos Calculados. JROMAN OOP 2 18-09-2003 02:02:36


La franja horaria es GMT +2. Ahora son las 08:31:36.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi