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
pc := 0.00; pg := 0.00; pu := 0.00; pva := 0.00; pf := 0.00; psinitbm := 0.00; pconitbm := 0.00; porcentajeG := 0.00; porcentajeU := 0.00; porcentajeV := 0.00; Gasto := 0.00; varios := 0.00; utilidad := 0.00; subtotalg := 0.00; subtotalv := 0.00; subtotalu := 0.00; 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); 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