public tb_sucursal_Info get_info(int IdEmpresa, int IdSucursal) { try { return(odata.get_info(IdEmpresa, IdSucursal)); } catch (Exception) { throw; } }
public cp_retencion_Info get_info_factura(int IdEmpresa, int IdTipoCbte_Ogiro, decimal IdCbteCble_Ogiro) { try { // ultima retencion no usada info_orden_giro = o_data_orden_giro.get_info_retencion(IdEmpresa, IdTipoCbte_Ogiro, IdCbteCble_Ogiro); tb_sucursal_Data data_sucursal = new tb_sucursal_Data(); var sucursal = data_sucursal.get_info(info_orden_giro.IdEmpresa, info_orden_giro.IdSucursal); info_retencion.IdSucursal_cxp = info_orden_giro.IdSucursal_cxp; info_retencion.IdEmpresa = info_orden_giro.IdEmpresa; info_retencion.IdProveedor = info_orden_giro.IdProveedor; info_retencion.IdSucursal = info_orden_giro.IdSucursal; info_retencion.serie1 = sucursal.Su_CodigoEstablecimiento; info_retencion.serie2 = "001"; info_retencion.NumRetencion = info_talonario.NumDocumento; info_retencion.IdTipoCbte_Ogiro = info_orden_giro.IdTipoCbte_Ogiro; info_retencion.IdCbteCble_Ogiro = info_orden_giro.IdCbteCble_Ogiro; info_retencion.co_baseImponible = info_orden_giro.co_total; info_retencion.co_serie = info_orden_giro.co_serie; info_retencion.co_factura = info_orden_giro.co_factura; info_retencion.co_subtotal_iva = info_orden_giro.co_subtotal_iva; info_retencion.co_valoriva = info_orden_giro.co_valoriva; info_retencion.co_subtotal_siniva = info_orden_giro.co_subtotal_siniva; info_retencion.Descripcion = info_orden_giro.Descripcion; info_retencion.pe_razonSocial = info_orden_giro.info_proveedor.info_persona.pe_razonSocial; info_retencion.observacion = info_orden_giro.co_observacion; info_retencion.fecha = info_orden_giro.co_FechaFactura; return(info_retencion); } catch (Exception) { throw; } }
public List <CONTA_003_balances_Info> get_list(int IdEmpresa, int IdAnio, DateTime fechaIni, DateTime fechaFin, string IdUsuario, int IdNivel, bool mostrarSaldo0, string balance, int IdSucursal, bool MostrarSaldoAcumulado) { try { List <CONTA_003_balances_Info> Lista; int IdSucursalIni = IdSucursal; int IdSucursalFin = IdSucursal == 0 ? 99999 : IdSucursal; if (IdSucursalFin == IdSucursalIni) { var info_sucursal = data_sucursal.get_info(IdEmpresa, IdSucursalIni); if (info_sucursal != null) { Su_Descripcion = info_sucursal.Su_Descripcion; } } else { Su_Descripcion = "TODAS"; } using (Entities_reportes Context = new Entities_reportes()) { Lista = (from q in Context.SPCONTA_003_balances(IdEmpresa, IdAnio, fechaIni, fechaFin, IdUsuario, IdNivel, mostrarSaldo0, balance, IdSucursalIni, IdSucursalFin, MostrarSaldoAcumulado) select new CONTA_003_balances_Info { IdUsuario = q.IdUsuario, IdEmpresa = q.IdEmpresa, IdCtaCble = q.IdCtaCble, pc_Cuenta = q.pc_Cuenta, IdCtaCblePadre = q.IdCtaCblePadre, EsCtaUtilidad = q.EsCtaUtilidad, IdNivelCta = q.IdNivelCta, IdGrupoCble = q.IdGrupoCble, gc_estado_financiero = q.gc_estado_financiero, gc_GrupoCble = q.gc_GrupoCble, gc_Orden = q.gc_Orden, Debitos = q.Debitos, DebitosSaldoInicial = q.DebitosSaldoInicial, SaldoDebitos = q.SaldoDebitos, SaldoDebitosCreditos = q.SaldoDebitosCreditos, Creditos = q.Creditos, CreditosSaldoInicial = q.CreditosSaldoInicial, SaldoCreditos = q.SaldoCreditos, SaldoFinal = q.SaldoFinal, SaldoInicial = q.SaldoInicial, EsCuentaMovimiento = q.EsCuentaMovimiento, Naturaleza = q.Naturaleza, SaldoCreditosNaturaleza = q.SaldoCreditosNaturaleza, SaldoDebitosCreditosNaturaleza = q.SaldoDebitosCreditosNaturaleza, SaldoDebitosNaturaleza = q.SaldoDebitosNaturaleza, SaldoFinalNaturaleza = q.SaldoFinalNaturaleza, SaldoInicialNaturaleza = q.SaldoInicialNaturaleza, Su_Descripcion = Su_Descripcion }).ToList(); } return(Lista); } catch (Exception) { throw; } }
public bool guardarDB(cp_orden_giro_Info info) { try { var prov = bus_proveedor.get_info(info.IdEmpresa, info.IdProveedor); info.co_baseImponible = info.co_subtotal_iva + info.co_subtotal_siniva; info.info_comrobante.IdEmpresa = info.IdEmpresa; info.info_comrobante.cb_Fecha = (DateTime)info.co_FechaContabilizacion; info.info_comrobante.IdSucursal = info.IdSucursal; info.info_comrobante.cb_Estado = "A"; info.info_comrobante.IdPeriodo = Convert.ToInt32(info.info_comrobante.cb_Fecha.Year.ToString() + info.info_comrobante.cb_Fecha.Month.ToString().PadLeft(2, '0')); info.info_comrobante.IdEmpresa = info.IdEmpresa; if (prov != null) { if (info.co_observacion == null) { info.co_observacion = ""; } info.info_comrobante.cb_Observacion = "Prov: " + prov.info_persona.pe_nombreCompleto + " FAC# " + info.co_serie + "-" + info.co_factura + " OBS: " + info.co_observacion; } else { info.info_comrobante.cb_Observacion = info.co_observacion; } info.co_valorpagar = info.co_total; info.co_FechaFactura_vct = info.co_FechaFactura_vct; info.co_fechaOg = info.co_FechaFactura; if (bus_contabilidad.guardarDB(info.info_comrobante)) { data = new cp_orden_giro_Data(); info.IdTipoCbte_Ogiro = info.info_comrobante.IdTipoCbte; info.IdCbteCble_Ogiro = info.info_comrobante.IdCbteCble; data.guardarDB(info); } if (info.info_forma_pago.codigo_pago_sri != null) { info.info_forma_pago.IdEmpresa = info.IdEmpresa; info.info_forma_pago.IdTipoCbte_Ogiro = info.IdTipoCbte_Ogiro; info.info_forma_pago.IdCbteCble_Ogiro = info.IdCbteCble_Ogiro; info.info_forma_pago.formas_pago_sri = ""; bus_forma_pago.GuardarDB(info.info_forma_pago); } if (info.info_retencion != null) { if (info.info_retencion.detalle.Count() > 0) { tb_sucursal_Data data_sucursal = new tb_sucursal_Data(); var sucursal = data_sucursal.get_info(info.IdEmpresa, info.IdSucursal); info.info_retencion.IdSucursal = info.IdSucursal; info.info_retencion.IdEmpresa = info.IdEmpresa; info.info_retencion.IdProveedor = info.IdProveedor; info.info_retencion.IdEmpresa_Ogiro = info.IdEmpresa; info.info_retencion.IdCbteCble_Ogiro = info.IdCbteCble_Ogiro; info.info_retencion.IdTipoCbte_Ogiro = info.IdTipoCbte_Ogiro; info.info_retencion.Fecha_Autorizacion = info.fecha_autorizacion; info.info_retencion.Descripcion = info.Descripcion; info.info_retencion.Estado = "A"; info.info_retencion.fecha = info.co_fechaOg; info.info_retencion.CodDocumentoTipo = cl_enumeradores.eTipoDocumento.RETEN.ToString(); info.info_retencion.IdUsuario = info.IdUsuario; info.info_retencion.observacion = "Retencion de factura #" + info.co_serie + '-' + info.co_factura; info.info_retencion.Fecha_Transac = Convert.ToDateTime(info.Fecha_Transac); info.info_retencion.aprobada_enviar_sri = false; if (bus_retencion.guardarDB(info.info_retencion)) { } } } return(true); } catch (Exception ex) { tb_LogError_Bus LogData = new tb_LogError_Bus(); LogData.GuardarDB(new tb_LogError_Info { Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "cp_orden_giro_Bus", Metodo = "guardarDB", IdUsuario = info.IdUsuario }); return(false); } }
public bool modificarDB(cp_orden_giro_Info info) { try { info.co_baseImponible = info.co_subtotal_iva + info.co_subtotal_siniva; info.info_comrobante.IdEmpresa = info.IdEmpresa; info.info_comrobante.IdTipoCbte = info.IdTipoCbte_Ogiro; info.info_comrobante.IdCbteCble = info.IdCbteCble_Ogiro; info.info_comrobante.cb_Fecha = (DateTime)info.co_FechaContabilizacion; info.info_comrobante.IdSucursal = info.IdSucursal; info.info_comrobante.cb_Estado = "A"; info.info_comrobante.IdPeriodo = Convert.ToInt32(info.info_comrobante.cb_Fecha.Year.ToString() + info.info_comrobante.cb_Fecha.Month.ToString().PadLeft(2, '0')); info.info_comrobante.IdEmpresa = info.IdEmpresa; info.info_comrobante.cb_Observacion = info.co_observacion; info.co_valorpagar = info.co_total; info.co_FechaFactura_vct = info.co_FechaFactura.AddDays(info.co_plazo); info.co_fechaOg = info.co_FechaFactura; if (bus_contabilidad.modificarDB(info.info_comrobante)) { data = new cp_orden_giro_Data(); info.IdTipoCbte_Ogiro = info.IdTipoCbte_Ogiro; info.IdCbteCble_Ogiro = info.IdCbteCble_Ogiro; data.modificarDB(info); } if (info.info_forma_pago.codigo_pago_sri != "" && info.info_forma_pago.codigo_pago_sri != null) { bus_forma_pago.EliminarDB(info.IdEmpresa, info.IdTipoCbte_Ogiro, info.IdCbteCble_Ogiro); info.info_forma_pago.IdEmpresa = info.IdEmpresa; info.info_forma_pago.IdTipoCbte_Ogiro = info.IdTipoCbte_Ogiro; info.info_forma_pago.IdCbteCble_Ogiro = info.IdCbteCble_Ogiro; info.info_forma_pago.formas_pago_sri = ""; bus_forma_pago.GuardarDB(info.info_forma_pago); } #region Modificar retencion y diario rtencion if (info.info_retencion != null) { if (info.info_retencion.detalle.Count() > 0) { tb_sucursal_Data data_sucursal = new tb_sucursal_Data(); var sucursal = data_sucursal.get_info(info.IdEmpresa, info.IdSucursal); info.info_retencion.IdEmpresa = info.IdEmpresa; info.info_retencion.IdProveedor = info.IdProveedor; info.info_retencion.IdEmpresa_Ogiro = info.IdEmpresa; info.info_retencion.IdCbteCble_Ogiro = info.IdCbteCble_Ogiro; info.info_retencion.IdTipoCbte_Ogiro = info.IdTipoCbte_Ogiro; info.info_retencion.Fecha_Autorizacion = info.fecha_autorizacion; info.info_retencion.IdSucursal = info.IdSucursal; info.info_retencion.Descripcion = info.Descripcion; info.info_retencion.Estado = "A"; info.info_retencion.fecha = info.co_fechaOg; info.info_retencion.CodDocumentoTipo = cl_enumeradores.eTipoDocumento.RETEN.ToString(); //if (info.info_retencion.serie1 == null) //{ // info.info_retencion.CodDocumentoTipo = cl_enumeradores.eTipoDocumento.RETEN.ToString(); // info.info_retencion.serie1 = sucursal.Su_CodigoEstablecimiento; // info.info_retencion.serie2 = "001"; //} //else //{ // info.info_retencion.CodDocumentoTipo = cl_enumeradores.eTipoDocumento.RETEN.ToString(); // info.info_retencion.serie1 = info.info_retencion.serie1; // info.info_retencion.serie2 = info.info_retencion.serie2; //} info.info_retencion.IdUsuario = info.IdUsuario; info.info_retencion.observacion = "Retencion de factura #" + info.co_serie + '-' + info.co_factura; info.info_retencion.Fecha_Transac = Convert.ToDateTime(info.Fecha_Transac); info.info_retencion.aprobada_enviar_sri = false; if (info.info_retencion.IdRetencion != 0) { if (bus_retencion.modificarDB(info.info_retencion)) { } } else if (bus_retencion.guardarDB(info.info_retencion)) { } } } #endregion return(true); } catch (Exception ex) { tb_LogError_Bus LogData = new tb_LogError_Bus(); LogData.GuardarDB(new tb_LogError_Info { Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "cp_orden_giro_Bus", Metodo = "modificarDB", IdUsuario = info.IdUsuario }); return(false); } }
public iva get_ats(int IdEmpresa, int IdPeriodo, int IdSucursal) { try { string registro = ""; iva ats = new iva(); info_periodo = data_periodo.get_info(IdEmpresa, IdPeriodo); info_empresa = data_empresa.get_info(IdEmpresa); ats_Info info_ats = get_info(IdEmpresa, IdPeriodo); #region cabecera del xml ats.IdInformante = info_empresa.em_ruc; ats.razonSocial = info_empresa.RazonSocial.Replace(".", " ").Replace("ñ", "n").Replace("Ñ", "N"); ats.Anio = info_periodo.IdanioFiscal.ToString(); ats.Mes = info_periodo.pe_mes.ToString().PadLeft(2, '0'); info_sucursal = data_sucursal.get_info(IdEmpresa, IdSucursal); ats.numEstabRuc = info_sucursal.Su_CodigoEstablecimiento.ToString().PadLeft(3, '0'); ats.TipoIDInformante = ivaTypeTipoIDInformante.R; ats.codigoOperativo = codigoOperativoType.IVA; ats.totalVentas = info_ats.lst_ventas.Sum(v => v.baseImpGrav + v.baseImpGrav); #endregion #region listado de compras if (info_ats.lst_compras != null) { if (info_ats.lst_compras.Count() > 0) { ats.compras = new List <detalleCompras>(); } info_ats.lst_compras.ForEach( comp => { detalleCompras comp_det = new detalleCompras(); registro = comp.denopr + " " + comp.secuencial; comp.denopr = cl_funciones.QuitartildesEspaciosPuntos(comp.denopr); comp_det.codSustento = comp.codSustento; comp_det.tpIdProv = comp.tpIdProv; comp_det.idProv = comp.idProv; comp_det.tipoComprobante = comp.tipoComprobante; comp_det.parteRel = parteRelType.NO; comp_det.fechaRegistro = comp.fechaRegistro.ToString().Substring(0, 10); comp_det.establecimiento = comp.establecimiento; comp_det.puntoEmision = comp.puntoEmision; comp_det.secuencial = comp.secuencial; comp_det.fechaEmision = comp.fechaEmision.ToString().Substring(0, 10); comp_det.autorizacion = comp.autorizacion; comp_det.baseNoGraIva = comp.baseNoGraIva.ToString("n2"); comp_det.baseImponible = comp.baseImponible.ToString("n2"); comp_det.baseImpGrav = comp.baseImpGrav.ToString("n2"); comp_det.baseImpExe = comp.baseImpExe.ToString("n2"); comp_det.montoIce = comp.montoIce.ToString("n2"); comp_det.montoIva = comp.montoIva.ToString("n2"); comp_det.valRetBien10 = "0.00"; comp_det.valRetServ20 = "0.00"; comp_det.valorRetBienes = "0.00"; comp_det.valRetServ50 = "0.00"; comp_det.valorRetServicios = "0.00"; comp_det.valRetServ100 = "0.00"; comp_det.totbasesImpReemb = "0.00"; comp_det.valRetBien10Specified = true; comp_det.valRetServ20Specified = true; comp_det.valRetServ50Specified = true; comp_det.totbasesImpReembSpecified = true; pagoExterior item_pago = new pagoExterior(); item_pago.pagoLocExt = (comp.pagoLocExt == "LOC") ? pagoLocExtType.Item01 : pagoLocExtType.Item02; item_pago.paisEfecPago = (item_pago.pagoLocExt == pagoLocExtType.Item01) ? "NA" : (comp.pagoLocExt != null || comp.pagoLocExt != "") ? comp.pagoLocExt : "NA"; item_pago.aplicConvDobTrib = aplicConvDobTribType.NA; item_pago.pagExtSujRetNorLeg = aplicConvDobTribType.NA; comp_det.pagoExterior = item_pago; if (comp_det.secuencial == "000001512") { } if (Convert.ToDecimal(comp.baseImponible) + Convert.ToDecimal(comp.baseImpGrav) >= 1000) { comp_det.formasDePago = null; string[] AFormaPago = { "20" }; comp_det.formasDePago = AFormaPago; } #region Reembolso if (comp.codSustento == "41") { comp_det.codSustento = "01"; comp_det.reembolsos = new List <reembolso>(); reembolso reem = new reembolso(); reem.tipoComprobanteReemb = "01"; reem.tpIdProvReemb = comp.tpIdProv; reem.idProvReemb = comp.idProv; reem.establecimientoReemb = comp.establecimiento; reem.puntoEmisionReemb = comp.puntoEmision; reem.secuencialReemb = comp.secuencial; reem.fechaEmisionReemb = comp.fechaEmision.ToString().Substring(0, 10); reem.autorizacionReemb = comp.autorizacion; reem.baseImponibleReemb = comp.baseImponible; reem.baseImpGravReemb = comp.baseImpGrav; reem.baseImpExeReemb = comp.baseImpExe; reem.montoIceRemb = comp.montoIce; reem.montoIvaRemb = comp.montoIva; comp_det.totbasesImpReembSpecified = true; comp_det.totbasesImpReemb = Convert.ToString(Convert.ToDecimal(comp.baseImponible) + Convert.ToDecimal(comp.baseImpGrav)); comp_det.reembolsos.Add(reem); } #endregion #region retencion por facturas if (info_ats.lst_retenciones != null) { if (info_ats.lst_retenciones.Count() > 0) { var lstret_x_fac = info_ats.lst_retenciones.Where(r => r.Cedula_ruc == comp.idProv & r.co_serie == comp.establecimiento + "-" + comp.puntoEmision & comp.secuencial == r.co_factura); if (lstret_x_fac != null) { if (lstret_x_fac.Count() > 0) { comp_det.air = new List <detalleAir>(); foreach (var item in lstret_x_fac) { if (item.re_tipo_Ret == "RTF") { comp_det.air.Add(new detalleAir { codRetAir = item.codRetAir.ToString(), baseImpAir = item.baseImpAir.ToString(), porcentajeAir = item.porcentajeAir.ToString(), valRetAir = item.valRetAir.ToString(), }); } else { if (item.porcentajeAir == "10") { comp_det.valRetBien10 = item.valRetAir.ToString(); } if (item.porcentajeAir == "20") { comp_det.valRetServ20 = item.valRetAir.ToString(); } if (item.porcentajeAir == "30") { comp_det.valorRetBienes = item.valRetAir.ToString(); } if (item.porcentajeAir == "50") { comp_det.valRetServ50 = item.valRetAir.ToString(); } if (item.porcentajeAir == "70") { comp_det.valorRetServicios = item.valRetAir.ToString(); } if (item.porcentajeAir == "100") { comp_det.valRetServ100 = item.valRetAir.ToString(); } } } } else // si no tiene retencion { comp_det.air = new List <detalleAir>(); comp_det.air.Add(new detalleAir { codRetAir = "332", baseImpAir = Convert.ToDecimal(comp.baseImpGrav + comp.baseImponible).ToString(), porcentajeAir = "0", valRetAir = "0.00", }); } } } } #endregion ats.compras.Add(comp_det); }); } #endregion #region Ventas if (info_ats.lst_ventas != null) { if (info_ats.lst_ventas.Count() > 0) { ats.ventas = new List <detalleVentas>(); info_ats.lst_ventas.ForEach( vent => { detalleVentas det_ventas = new detalleVentas(); det_ventas.tpIdCliente = vent.tpIdCliente; det_ventas.idCliente = vent.idCliente; if (det_ventas.tpIdCliente == " 04" | det_ventas.tpIdCliente == " 05" | det_ventas.tpIdCliente == " 06") { det_ventas.parteRelVtas = parteRelType.NO; } vent.DenoCli = cl_funciones.QuitartildesEspaciosPuntos(vent.DenoCli); det_ventas.tipoComprobante = vent.tipoComprobante; det_ventas.tipoEmision = tipoEmisionType.F; det_ventas.numeroComprobantes = vent.numeroComprobantes.ToString(); det_ventas.baseNoGraIva = vent.baseNoGraIva; det_ventas.baseImponible = vent.baseImponible; det_ventas.baseImpGrav = vent.baseImpGrav; det_ventas.montoIva = vent.montoIva; det_ventas.montoIce = vent.montoIce; det_ventas.valorRetIva = vent.valorRetIva.ToString("n2"); det_ventas.valorRetRenta = vent.valorRetRenta.ToString("n2"); det_ventas.montoIceSpecified = true; det_ventas.formasDePago = null; string[] AFormaPago = { "20" }; det_ventas.formasDePago = AFormaPago; ats.ventas.Add(det_ventas); } ); } } #endregion #region ventas por establecimientos if (info_ats.lst_ventas != null) { if (info_ats.lst_ventas.Count() > 0) { ats.ventasEstablecimiento = new List <ventaEst>(); var vtas = info_ats.lst_ventas.GroupBy(x => x.codEstab) .Select(x => new { codEstab = x.Key, ventasEstab = x.Sum(y => y.ventasEstab) }).ToList(); foreach (var item in vtas) { ventaEst vtas_esta = new ventaEst(); vtas_esta.codEstab = item.codEstab; vtas_esta.ventasEstab = item.ventasEstab; vtas_esta.ivaComp = Convert.ToDecimal("0.00"); ats.ventasEstablecimiento.Add(vtas_esta); } } } #endregion #region exportaciones if (info_ats.lst_exportaciones != null) { if (info_ats.lst_exportaciones.Count() > 0) { ats.exportaciones = new List <detalleExportacionesType>(); info_ats.lst_exportaciones.ForEach ( exp => { detalleExportacionesType exp_det = new detalleExportacionesType(); exp_det.tpIdClienteEx = exp.tpIdClienteEx; exp_det.idClienteEx = exp.idClienteEx; exp_det.parteRelExp = parteRelType.NO; exp_det.tipoCli = "02"; exp_det.denoExpCli = exp.denoExpCli = cl_funciones.QuitartildesEspaciosPuntos(exp.denoExpCli); exp_det.tipoRegi = tipoRegiType.Item01; exp_det.paisEfecPagoGen = exp.paisEfecPagoGen; exp_det.paisEfecExp = exp.paisEfecExp; exp_det.exportacionDe = exp.exportacionDe; exp_det.tipoComprobante = exp.tipoComprobante; exp_det.fechaEmbarque = exp.fechaEmbarque.ToString().Substring(0, 10); exp_det.valorFOB = (exp.valorFOB) == null?Convert.ToDecimal(0.00):Convert.ToDecimal(exp.valorFOB); exp_det.valorFOBComprobante = (exp.valorFOB) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(exp.valorFOBComprobante); exp_det.establecimiento = exp.establecimiento; exp_det.puntoEmision = exp.puntoEmision; exp_det.secuencial = exp.secuencial; exp_det.autorizacion = (exp.autorizacion) == null?"34345454656453":exp.autorizacion; exp_det.fechaEmision = exp.fechaEmision.ToString().Substring(0, 10); //exp_det.pagoRegFisSpecified = true; exp_det.parteRelExpSpecified = true; exp_det.tipoRegiSpecified = true; //exp_det.impuestoOtroPaisSpecified = true; //exp_det.ingExtGravOtroPaisSpecified = true; ats.exportaciones.Add(exp_det); } ); } } #endregion #region Anulados if (info_ats.lst_exportaciones != null) { if (info_ats.lst_anulados.Count() > 0) { ats.anulados = new List <detalleAnulados>(); info_ats.lst_anulados.ForEach ( anu => { detalleAnulados anula = new detalleAnulados(); anula.tipoComprobante = anu.tipoComprobante; anula.establecimiento = anu.Establecimiento; anula.puntoEmision = anu.puntoEmision; anula.secuencialInicio = anu.secuencialInicio; anula.secuencialFin = anu.secuencialFin; anula.autorizacion = anu.Autorizacion; ats.anulados.Add(anula); } ); } } #endregion ats.totalVentas = info_ats.lst_ventas.Sum(y => y.ventasEstab); ats.totalVentasSpecified = true; return(ats); } catch (Exception e) { throw; } }
public bool guardarDB(cp_orden_giro_Info info) { try { var prov = bus_proveedor.get_info(info.IdEmpresa, info.IdProveedor); info.co_baseImponible = info.co_subtotal_iva + info.co_subtotal_siniva; info.info_comrobante.IdEmpresa = info.IdEmpresa; info.info_comrobante.cb_Fecha = (DateTime)info.co_FechaContabilizacion; info.info_comrobante.IdSucursal = info.IdSucursal; info.info_comrobante.cb_Estado = "A"; info.info_comrobante.IdPeriodo = Convert.ToInt32(info.info_comrobante.cb_Fecha.Year.ToString() + info.info_comrobante.cb_Fecha.Month.ToString().PadLeft(2, '0')); info.info_comrobante.IdEmpresa = info.IdEmpresa; if (prov != null) { if (info.co_observacion == null) { info.co_observacion = ""; } info.info_comrobante.cb_Observacion = "Prov: " + prov.info_persona.pe_nombreCompleto + " FAC# " + info.co_serie + "-" + info.co_factura + " OBS: " + info.co_observacion; } else { info.info_comrobante.cb_Observacion = info.co_observacion; } info.co_valorpagar = info.co_total; if (info.info_cuota.Total_a_pagar == 0) { info.co_FechaFactura_vct = info.co_FechaFactura; } else { info.co_FechaFactura_vct = info.co_FechaFactura_vct; } info.co_fechaOg = info.co_FechaFactura; if (bus_contabilidad.guardarDB(info.info_comrobante)) { data = new cp_orden_giro_Data(); info.IdTipoCbte_Ogiro = info.info_comrobante.IdTipoCbte; info.IdCbteCble_Ogiro = info.info_comrobante.IdCbteCble; data.guardarDB(info); } if (info.info_cuota.Dias_plazo != 0 & info.info_cuota.Total_a_pagar != 0 & info.info_cuota.lst_cuotas_det.Count() > 0 ) { bus_cuotas = new cp_cuotas_x_doc_Bus(); info.info_cuota.IdEmpresa = info.IdEmpresa; info.info_cuota.IdTipoCbte = info.info_comrobante.IdTipoCbte; info.info_cuota.IdCbteCble = info.info_comrobante.IdCbteCble; info.info_cuota.Observacion = info.co_observacion; info.info_cuota.Estado = true; if (info.info_cuota.Fecha_inicio.Year == 1) { info.info_cuota.Fecha_inicio = info.co_FechaFactura; } bus_cuotas.GuardarDB(info.info_cuota); } if (info.info_forma_pago.codigo_pago_sri != null) { info.info_forma_pago.IdEmpresa = info.IdEmpresa; info.info_forma_pago.IdTipoCbte_Ogiro = info.IdTipoCbte_Ogiro; info.info_forma_pago.IdCbteCble_Ogiro = info.IdCbteCble_Ogiro; info.info_forma_pago.formas_pago_sri = ""; bus_forma_pago.GuardarDB(info.info_forma_pago); } if (info.info_retencion != null) { if (info.info_retencion.detalle.Count() > 0) { tb_sucursal_Data data_sucursal = new tb_sucursal_Data(); var sucursal = data_sucursal.get_info(info.IdEmpresa, info.IdSucursal); info.info_retencion.IdSucursal = info.IdSucursal; info.info_retencion.IdEmpresa = info.IdEmpresa; info.info_retencion.IdProveedor = info.IdProveedor; info.info_retencion.IdEmpresa_Ogiro = info.IdEmpresa; info.info_retencion.IdCbteCble_Ogiro = info.IdCbteCble_Ogiro; info.info_retencion.IdTipoCbte_Ogiro = info.IdTipoCbte_Ogiro; info.info_retencion.Fecha_Autorizacion = info.fecha_autorizacion; info.info_retencion.Descripcion = info.Descripcion; info.info_retencion.Estado = "A"; info.info_retencion.fecha = info.co_fechaOg; info.info_retencion.CodDocumentoTipo = cl_enumeradores.eTipoDocumento.RETEN.ToString(); info.info_retencion.serie1 = sucursal.Su_CodigoEstablecimiento; info.info_retencion.serie2 = "001"; info.info_retencion.re_EstaImpresa = "N"; info.info_retencion.re_Tiene_RFuente = "S"; info.info_retencion.re_Tiene_RTiva = "S"; info.info_retencion.IdUsuario = info.IdUsuario; info.info_retencion.observacion = "Retencion de factura #" + info.co_serie + '-' + info.co_factura; info.info_retencion.Fecha_Transac = Convert.ToDateTime(info.Fecha_Transac); info.info_retencion.aprobada_enviar_sri = false; if (bus_retencion.guardarDB(info.info_retencion)) { } } } return(true); } catch (Exception) { throw; } }