Hola Chicos lastimosamente la impresora fiscal tiene una dll llamada BEMAFI32.dll el cual llama una funciones en el que están dentro de una unidad que la llame declaraciones y busque cómo la impresora realiza el redondeo y solamente tiene esto:
Código Delphi
[-]function Bematech_FI_ProgramaRedondeo: Integer; StdCall;
External 'BEMAFI32.DLL';
más nada jejeje igual que otras funciones que utilizo.
en cuanto a código de ejemplo hago lo siguiente:
Código Delphi
[-]
procedure TfrmFacturacionPrincipal.AgregaProductosaVenta;
Var
codigo, Descripcion, wimpuesto, Cantidad, Precio, wdescuento: AnsiString;
CIva: String;
letraimpuesto: AnsiString;
totalivapv, TotalSubVentaFac, TotalSubVentaFacU: Double; totalivapvr: Double; DescProducto, pventapro: Double;
begin
IdArticuloPro := 0;
wcodigobarras := Trim(Self.eConsultaArticulo.Text);
if wcodigobarras <> '' then
begin
ConsultaCantidadArt; with dmConexion.qConsultaArtInventario do
begin
Close;
sql.Clear;
sql.Add('select a.ID_ARTICULO idAtriculo, a.COD_BARRA, a.NOMBRE, ');
sql.Add(' a.DESCRIPCION, A.GRAVADO,a.CANTIDAD, i.PORCENTAJE, ');
sql.Add('p.PRECIO_CIV, p.PRECIO_SIV from ARTICULOS a , ARTXIMPUES ai, ');
sql.Add('impuesto i, PRECIO p ');
sql.Add(' where a.ID_ARTICULO = ai.ID_ARTICULO ');
sql.Add('and i.ID_IMPUESTO = ai.ID_IMPUESTO ');
sql.Add('and p.ID_ARTICULO = a.ID_ARTICULO ');
sql.Add('and p.ID_ARTXIMPUES = ai.ID_ARTXIMPUES');
sql.Add('AND A.cod_barra=codigo_barras');
Params.ParamByName('pcodigo_barras').Value := wcodigobarras;
try
if wcantidad_venta = 0 then
begin
wcantidad_venta := 1;
end;
Open;
finally
eConsultaArticulo.Clear;
eConsultaArticulo.SetFocus;
end;
end;
IdArticuloPro := dmConexion.qConsultaArtInventarioIDATRICULO.AsInteger;
ConsultaDescArt(IdArticuloPro);
if DescxArt > 1 then
begin
precioUV := dmConexion.qConsultaArtInventarioPRECIO_SIV.AsFloat;
precioUVSinDes := dmConexion.qConsultaArtInventarioPRECIO_SIV.AsFloat;
DescProducto := precioUV * DescxArt / 100;
precioUV := precioUV - DescProducto;
precioUVSinDes := simpleroundto(precioUVSinDes, -2);
Precio := Format('%n', [precioUVSinDes]);
end
else
begin
DescProducto := StrToFloat('0.00');
precioUV := dmConexion.qConsultaArtInventarioPRECIO_SIV.AsFloat;
precioUVSinDes := dmConexion.qConsultaArtInventarioPRECIO_SIV.AsFloat;
precioUVSinDes := simpleroundto(precioUVSinDes, -2);
Precio := Format('%n', [precioUVSinDes]);
end;
cantv := wcantidad_venta;
precioUV := simpleroundto(precioUV, -2);
CalCantxPU;
if cuentaARt = cuentaARt then
begin
cuentaARt := cuentaARt + 1;
end
else
begin
cuentaARt := 0;
end;
dmlogicaventa.cdsTempArtVenta.Append;
dmlogicaventa.cdsTempArtVentacdsTempArtVentaART.AsString :=
inttostr(cuentaARt);
dmlogicaventa.cdsTempArtVentacdsTempArtVentaIDARTICULO.AsInteger :=
dmConexion.qConsultaArtInventarioIDATRICULO.AsInteger;
dmlogicaventa.cdsTempArtVentacdsTempArtVentaCOD_BARRA.AsString :=
dmConexion.qConsultaArtInventarioCOD_BARRA.AsString;
dmlogicaventa.cdsTempArtVentacdsTempArtVentaNOMBRE.AsString :=
dmConexion.qConsultaArtInventarioNOMBRE.AsString;
dmlogicaventa.cdsTempArtVentacdsTempArtVentaCANTIDAD.AsString :=
floattostr(cantv);
dmlogicaventa.cdsTempArtVentacdsTempArtVentaPUnitario.AsFloat :=
dmConexion.qConsultaArtInventarioPRECIO_SIV.AsFloat;
dmlogicaventa.cdsTempArtVentacdsTempArtVentaConDesc.AsFloat :=
cantv * precioUVSinDes;
dmlogicaventa.cdsTempArtVentacdsTempArtVentaSUBTOTAL.AsFloat :=
cantv * precioUV;
dmlogicaventa.cdsTempArtVentacdsTempArtVentaDESCUENTO.AsFloat :=
simpleroundto(DescProducto, -2);
if dmConexion.qConsultaArtInventarioPORCENTAJE.AsString = '0' then
begin
exento := exento +
dmlogicaventa.cdsTempArtVentacdsTempArtVentaSUBTOTAL.AsFloat;
letraimpuesto := 'E';
dmlogicaventa.cdsTempArtVentacdsTempArtVentaIMPUESTO.AsString :=
letraimpuesto;
end
else
begin
if dmConexion.qConsultaArtInventarioPORCENTAJE.AsString = '7' then
begin
dmlogicaventa.cdsTempArtVentacdsTempArtVentaIMPUESTO.AsString :=
floattostr(dmConexion.qConsultaArtInventarioPORCENTAJE.AsFloat);
montoImpuesto := montoImpuesto +
dmlogicaventa.cdsTempArtVentacdsTempArtVentaSUBTOTAL.AsFloat * 0.07;
end;
if dmConexion.qConsultaArtInventarioPORCENTAJE.AsString = '10' then
begin
dmlogicaventa.cdsTempArtVentacdsTempArtVentaIMPUESTO.AsString :=
floattostr(dmConexion.qConsultaArtInventarioPORCENTAJE.AsFloat);
montoImpuesto1 := montoImpuesto1 +
dmlogicaventa.cdsTempArtVentacdsTempArtVentaSUBTOTAL.AsFloat * 0.10;
end;
if dmConexion.qConsultaArtInventarioPORCENTAJE.AsString = '15' then
begin
dmlogicaventa.cdsTempArtVentacdsTempArtVentaIMPUESTO.AsString :=
floattostr(dmConexion.qConsultaArtInventarioPORCENTAJE.AsFloat);
montoImpuesto2 := montoImpuesto2 +
dmlogicaventa.cdsTempArtVentacdsTempArtVentaSUBTOTAL.AsFloat * 0.15;
end;
end;
totalivapv := simpleroundto
((precioUV * dmConexion.qConsultaArtInventarioPORCENTAJE.AsFloat / 100),
-2) * cantv; pventapro := totalivapv + TotalCantxPU;
dmlogicaventa.cdsTempArtVentacdsTempArtVentaPRECIOVENTA.AsFloat :=
redondeo(pventapro, 2);
dmlogicaventa.cdsTempArtVenta.Post;
TotalSubVentaFacU := pventapro;
TotalSubVentaFac := TotalSubVentaFacU + pventapro;
codigo := dmConexion.qConsultaArtInventarioCOD_BARRA.AsString;
Descripcion := dmConexion.qConsultaArtInventarioNOMBRE.AsString;
Impuesto := dmConexion.qConsultaArtInventarioPORCENTAJE.AsFloat;
CIva := floattostr(Impuesto);
ConsultaIVA := StrToInt(CIva); case ConsultaIVA of 7:
begin
wimpuesto := '0700';
eSiete.Text := FloatToStrF(montoImpuesto, ffCurrency, 12, 2);
end;
10:
begin
wimpuesto := '1000';
eDiez.Text := FloatToStrF(montoImpuesto1, ffCurrency, 12, 2);
end;
15:
begin
wimpuesto := '1500';
eQuince.Text := FloatToStrF(montoImpuesto2, ffCurrency, 12, 2);
end;
0:
begin
wimpuesto := 'II';
eExentos.Text := FloatToStrF(exento, ffCurrency, 12, 2);
end;
end;
total_impuestos := (montoImpuesto + montoImpuesto1 + montoImpuesto2);
Cantidad := floattostr(cantv);
DescProducto := simpleroundto(DescProducto, -2);
wdescuento := floattostr(DescProducto);
wcantidad_venta := 0;
eConsultaArticulo.SetFocus;
desc := desc + DescProducto;
eDescuentos.Text := FloatToStrF(desc, ffCurrency, 12, 2);
subtotalventasinDesc := dmlogicaventa.cdsTempArtVentaSUBTODESVENTA.Value;
subtotalventasinDesc := simpleroundto(subtotalventasinDesc, -2);
eSubSinDesc.Text := FloatToStrF(subtotalventasinDesc, ffCurrency, 12, 2);
subtotalventa := dmlogicaventa.cdsTempArtVentaSUBTOTALVENTA.Value;
subtotalventa := simpleroundto(subtotalventa, -2);
eSubTotalVenta.Text := FloatToStrF(subtotalventa, ffCurrency, 12, 2);
kondbgrid := dbgVentas.DataSource.DataSet.RecordCount;
lblProductosCant.Caption := inttostr(kondbgrid);
total_impuestos := simpleroundto(total_impuestos, -2);
eImpuestos.Text := FloatToStrF(total_impuestos, ffCurrency, 12, 2);
ventatotalfactura := subtotalventa + total_impuestos;
ventatotalfactura := simpleroundto(ventatotalfactura, -2);
eTotalVenta.Text := FloatToStrF(ventatotalfactura, ffCurrency, 12, 2);
end;
iRetorno := Bematech_FI_EspacioEntreLineas(004);
Bematech_FI_VendeArticulo(codigo, Descripcion, wimpuesto, 'I', Cantidad, 2,
Precio, '$', wdescuento);
end;
Saludos
novato_erick