public void Facturador(int idVenta, DataGridView dtDetalle) { if (this.lblBanderaComprobante.Text != "0") { enviarFormaPago(); int? tipoDoc; string cantidad, codigo, descr, valorUnitario, dcto, importe, nroDoc, nombre; decimal igvUn, afecIgv, valUn; if (this.txtDocumento.Text.Length == 8) { tipoDoc = 1; nroDoc = this.txtDocumento.Text.Trim(); } else if (this.txtDocumento.Text.Length == 11) { tipoDoc = 6; nroDoc = this.txtDocumento.Text.Trim(); } else { tipoDoc = 1; nroDoc = "0"; } if (this.txtNombre.Text == string.Empty) { nombre = "SIN DNI"; } else { nombre = this.txtNombre.Text.Trim(); } string tipoCompr = ""; if (this.lblBanderaComprobante.Text == "1") { tipoCompr = "BOLETA"; } else if (this.lblBanderaComprobante.Text == "2") { tipoCompr = "FACTURA"; } NFacturador.registrarComprobanteCabecera("01", DateTime.Now.ToString("yyyy-MM-dd"), "", tipoDoc, nroDoc, nombre, "PEN", this.lblDctoGeneral.Text.Trim(), "0.00", this.lblDctoGeneral.Text.Trim(), this.lblSubTotal.Text.Trim(), "0.00", "0.00", this.lblIgv.Text.Trim(), "0.00", "0.00", this.lblTotal.Text.Trim(), tipoCompr, idVenta); for (int i = 0; i < dtDetalle.Rows.Count; i++) { cantidad = dtDetalle.Rows[i].Cells[2].Value.ToString(); codigo = dtDetalle.Rows[i].Cells[0].Value.ToString(); descr = dtDetalle.Rows[i].Cells[1].Value.ToString(); valorUnitario = dtDetalle.Rows[i].Cells[3].Value.ToString(); valUn = Convert.ToDecimal(valorUnitario); dcto = dtDetalle.Rows[i].Cells[4].Value.ToString(); igvUn = Convert.ToDecimal(valorUnitario) * (18 / 100); afecIgv = (Convert.ToDecimal(cantidad) * Convert.ToDecimal(valorUnitario)) * 0.18m; importe = dtDetalle.Rows[i].Cells[6].Value.ToString(); decimal mtoDsctoItem = Convert.ToDecimal(dcto) / Convert.ToDecimal(cantidad); decimal mtoPrecioVentaItem = Decimal.Round((Convert.ToDecimal(importe) / 1.18m), 2); decimal mtoIgvItem = Convert.ToDecimal(importe) - mtoPrecioVentaItem; decimal mtoValorUnitario = Decimal.Round(mtoPrecioVentaItem / Convert.ToDecimal(cantidad), 2); NFacturador.registrarComprobanteDetalle("NIU", cantidad, codigo, "", descr, mtoValorUnitario.ToString("#0.00#"), mtoDsctoItem.ToString("#0.00#"), mtoIgvItem.ToString("#0.00#"), "10", "0.00", "", mtoPrecioVentaItem.ToString("#0.00#"), importe, tipoCompr, idVenta); /* NFacturador.registrarComprobanteDetalle("NIU", cantidad, codigo, "", descr, (valUn - igvUn).ToString(), dcto, igvUn.ToString(), "10", "0.00", "", valorUnitario, * importe, tipoCompr, idVenta);¨*/ } } }
public void Facturador(int idVenta, DataTable dtDetalle) { int? tipoDoc; string cantidad, codigo, descr, valorUnitario, dcto, importe, nroDoc, nombre; decimal igvUn, afecIgv, valUn; if (this.lblNroDoc.Text.Length == 8) { tipoDoc = 1; nroDoc = this.lblNroDoc.Text.Trim(); } else if (this.lblNroDoc.Text.Length == 11) { tipoDoc = 6; nroDoc = this.lblNroDoc.Text.Trim(); } else { tipoDoc = 1; nroDoc = "0"; } if (this.lblCliente.Text == string.Empty) { nombre = "SIN DNI"; } else { nombre = this.lblCliente.Text.Trim(); } string tipoCompr = ""; if (this.lblTipoComprobante.Text == "Boleta") { tipoCompr = "BOLETA"; } else if (this.lblTipoComprobante.Text == "Factura") { tipoCompr = "FACTURA"; } decimal total = Convert.ToDecimal(this.lblTotal.Text); decimal igv = Decimal.Round(total / 1.18m, 2); decimal subTotal = total - igv; NFacturador.registrarComprobanteCabecera("01", DateTime.Now.ToString("yyyy-MM-dd"), "", tipoDoc, nroDoc, nombre, "PEN", "00.00", "0.00", "00.00", subTotal.ToString(), "00.00", "0.00", igv.ToString(), "0.00", "0.00", this.lblTotal.Text, tipoCompr, idVenta); for (int i = 0; i < dtDetalle.Rows.Count; i++) { cantidad = dtDetalle.Rows[i]["Cant"].ToString(); codigo = dtDetalle.Rows[i]["Cod"].ToString(); descr = dtDetalle.Rows[i]["Descripcion"].ToString(); valorUnitario = dtDetalle.Rows[i]["Precio_Un"].ToString(); valUn = Convert.ToDecimal(valorUnitario); dcto = dtDetalle.Rows[i]["Descuento"].ToString(); igvUn = Convert.ToDecimal(valorUnitario) * (18 / 100); afecIgv = (Convert.ToDecimal(cantidad) * Convert.ToDecimal(valorUnitario)) * 0.18m; importe = dtDetalle.Rows[i]["Importe"].ToString(); decimal mtoDsctoItem = Convert.ToDecimal(dcto) / Convert.ToDecimal(cantidad); decimal mtoPrecioVentaItem = Decimal.Round((Convert.ToDecimal(importe) / 1.18m), 2); decimal mtoIgvItem = Convert.ToDecimal(importe) - mtoPrecioVentaItem; decimal mtoValorUnitario = mtoPrecioVentaItem / Convert.ToDecimal(cantidad); NFacturador.registrarComprobanteDetalle("NIU", cantidad, codigo, "", descr, mtoValorUnitario.ToString("#0.00#"), mtoDsctoItem.ToString("#0.00#"), mtoIgvItem.ToString("#0.00#"), "10", "0.00", "", mtoPrecioVentaItem.ToString("#0.00#"), importe, tipoCompr, idVenta); } }