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

Respuesta
 
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
  #2  
Antiguo 24-08-2011
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Poder: 25
Caral Va por buen camino
Hola
Uffff, que montón de código.
Sin verlo mucho (por que me canse) te diría que no es bueno colocar el impuesto en un campo fijo, los Países tienen la manía de cambiarlos según su interés.
Saludos
__________________
Siempre Novato
Responder Con Cita
  #3  
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
jajajaja si Caral sabia que alguien me diría eso pero bueno soy novato aun no me atrevo a correr...

pero en fin es una aplicación a nivel local no se me había ocurrido eso Gracias por la sugerencia... problema que menciono será por eso?.. bueno aparentemente dice que mi variable pc lo toma del dbePCompra.Text y que el impuesto es simplemente la variable psinitbm vendra a ser la variable pc;

eso es el error? noooo creo ...

Saludos

Cita:
Disculpen el montón de código pero no me imagino como darme a explicar mi procedimiento
Responder Con Cita
  #4  
Antiguo 24-08-2011
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Poder: 25
Caral Va por buen camino
Hola
Veo poco, pero:
1: las variables las declaras publicas ???, donde estan, (solo veo i : Integer)
2: Las variables obtienen su valor de los edits (me parece) entonces por que las declararlas con 0.00 ????.
No entiendo muy bien el concepto que tienes al hacer tantos calculos y con tantas opciones diferentes en un procedimiento, me imagino que estoy viejo y esto es lo moderno.
Saludos
__________________
Siempre Novato
Responder Con Cita
  #5  
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
jajaja disculpa si mis variables son publicas y las declaro con 0.00 para inicializarlas... Me estoy equivocando en algo?

Código Delphi [-]
public
    { Public declarations }
    Gasto, porcentajeG, porcentajeU, porcentajeV, pc, pg, pu, pva, pf, psinitbm,
      pconitbm, varios, utilidad, subtotalg, subtotalv, subtotalu, Gasto2,
      porcentajeG2, porcentajeU2, porcentajeV2, psinitbm2, pconitbm2, varios2,
      utilidad2, subtotalg2, subtotalv2, subtotalu2, Gasto3, porcentajeG3,
      porcentajeU3, porcentajeV3, psinitbm3, pconitbm3, varios3, utilidad3,
      subtotalg3, subtotalv3, subtotalu3, tempPrecio, porcentajeImpuestoG,
      porcentajeIMpuestoU, porcentajeIMpuestoV, porcentajeImpuestoG2,
      porcentajeIMpuestoU2, porcentajeIMpuestoV2, porcentajeImpuestoG3,
      porcentajeIMpuestoU3, porcentajeIMpuestoV3: Double;
    impuesto: Integer;

usted sabe no es moderno solo improviso...

jajajaj

Gracias Caral...
Responder Con Cita
  #6  
Antiguo 24-08-2011
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Poder: 25
Caral Va por buen camino
Hola
Si te empeñas en usar variables deberias declararlas en el procedimiento ya que se deberian iniciar y eliminar, asi no tendrias que colocarles un valor de inicio, este deberia de estar en los edit.
No entiendo muy bien lo que quieres hacer por eso solo opino.
Saludos
__________________
Siempre Novato
Responder Con Cita
Respuesta



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 22:01:44.


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