Ver Mensaje Individual
  #3  
Antiguo 20-01-2016
Camilo Camilo is offline
Miembro
 
Registrado: jun 2007
Posts: 147
Reputación: 17
Camilo Va por buen camino
Gracias amigo AzidRain por el tiempo que te tomas para ayudarme.
Con este codigo Llamo algunas funciones financieras que dan error en algunas maquinas. Se activa cuando rayamos un codigo de barras.

Código Delphi [-]
procedure TFVenta.Edit1Exit(Sender: TObject);
begin
if Trim(Edit1.Text) <> '' then
  // Esta lleno
  begin
  Actualiza;
  SumaCantidad;
  Impuesto;
  SumarImp;
  Subtotal;
  end
else
  // No esta lleno
end;

Las funciones son las siguientes:

Código Delphi [-]
Procedure TFVenta.Actualiza;
begin
with DataModule1.IBQInventarios do begin
  if active then Close; //Agregué aquí
  sql.Clear; // y aquí
  SQL.Add('Select * From INVENTARIO');
  SQL.Add('Where Codigo_Producto = '+QuotedStr(Edit1.Text));
  Open;
  if not IsEmpty then begin
StringGrid1.Row := StringGrid1.Rowcount - 1;
StringGrid1.Cells[0, StringGrid1.Row]:= fieldbyname('CODIGO_PRODUCTO').AsString;
StringGrid1.Cells[1, StringGrid1.Row]:= fieldbyname('NOMBRE_PRODUCTO').AsString;
StringGrid1.Cells[2, StringGrid1.Row]:= fieldbyname('REFERENCIA_PRODUCTO').AsString;
StringGrid1.Cells[3, StringGrid1.Row]:= fieldbyname('CATEGORIA').AsString;
StringGrid1.Cells[4, StringGrid1.Row]:= '1';   //CANTIDAD
StringGrid1.Cells[5, StringGrid1.Row]:= fieldbyname('PRECIO').AsString;

  Edit1.Clear;
  Edit1.SetFocus;
  StringGrid1.RowCount := StringGrid1.RowCount + 1;
  Sumar;
  Puntos;

  end else begin
  ShowMessage('PRODUCTO NO EXISTE EN INVENTARIO');
  Edit1.Clear;

  Edit1.SetFocus;
  end;
end;
end;


Código Delphi [-]
Procedure TFVenta.SumaCantidad;
var
k, Suma: integer;
a, c, d: Extended;
begin
  d:= 0;
  a := StrToInt(StringGrid1.Cells[5, StringGrid1.Row]); // Precio
  c := StrToInt(Edit8.Text); //Cantidad
  d:=  (a*c); // Precio x Cantidad

StringGrid1.Cells[4, StringGrid1.Row]:=  Edit8.Text;  //CANTIDAD
StringGrid1.Cells[6, StringGrid1.Row]:=  FormatFloat('$ #0,.00',d);
StringGrid1.Cells[8, StringGrid1.Row]:= FloatToStr(d);

Suma := 0;
  StringGrid1.Cells[7, StringGrid1.Row]:= StringGrid1.Cells[1, StringGrid1.Row];
  for k := 0 to StringGrid1.RowCount - 1 do
    if k <= StringGrid1.RowCount - 1 then
      Suma := Suma + StrToIntdef(StringGrid1.Cells[8, k + 1], 0);
      Edit7.Text:=  FormatFloat('$ #0,.00', Suma);
      Edit5.Text:=  IntToStr(Suma);
end;

Código Delphi [-]
Procedure TFVenta.Impuesto;
begin
DataModule1.IBQInvFact.Close;
DataModule1.IBQInvFact.ParamByName('Codigo').AsString := StringGrid1.Cells[0, StringGrid1.Row];
DataModule1.IBQInvFact.Open;
end;

Código Delphi [-]
Procedure TFVenta.SumarImp;
var
 a,b,c,d,e,f,z: Extended;
 j, Suma: integer;
begin
  z:= 0;
  a:= StrToInt(DbEdit2.Text);   //Iva
  b:= StrToInt(DbEdit3.Text);   //Otro_Imp
  c:= 1+((a+b)/100); //   Suma Impuestos
  d:= StrToInt(StringGrid1.Cells[5, StringGrid1.Row])* StrToInt(StringGrid1.Cells[4, StringGrid1.Row]); // Precio
  f:= d/c;
  z:= d-f;

  if z > 0 then

StringGrid1.Cells[7, StringGrid1.Row]:=  FormatFloat('#####', z)
else
  StringGrid1.Cells[7, StringGrid1.Row]:=  ('0');
Suma := 0;
  StringGrid1.Cells[7, StringGrid1.Row];
  for j := 0 to StringGrid1.RowCount - 1 do
    if j <= StringGrid1.RowCount - 1 then
      Suma := Suma + StrToIntdef(StringGrid1.Cells[7, j + 1], 0);
      Edit2.Text:=  FormatFloat('$ #0,.00', Suma);
      Edit14.Text:=  IntToStr(Suma);
end;

Código Delphi [-]
Procedure  TFVenta.Subtotal;
var
Precio, Impuesto, Resultado: Extended;
begin
Precio:= StrToInt(Edit5.Text);
Impuesto:= StrToInt(Edit14.Text);
Resultado:= ((Precio - Impuesto));
Edit4.text:= FormatFloat('$ #0,.00', Resultado);
Edit16.Text:=  FloatToStr(Resultado);
end;

Lo de las variables me suena muy logico. solo quiero si no es molestia que revises los codigos para que me ratifiques o como tu mismo dices, no especular.
Gracias amigo y a todos los que tengan a bien opinar y aportar sobre el tema.
Responder Con Cita