(factura-e-mode-exportarl) avances en exportado de factura electronica

develop
Gerardo 2023-08-11 08:46:15 +02:00
parent 80751b0889
commit 4cbf5df086
8 changed files with 240 additions and 58 deletions

View File

@ -336,7 +336,7 @@ namespace Exferia_Aplicacion.General
public static string G_STR_MENSAJES_DOCUMENTO_VOLCADO_REVISARLINEASVOLCADO() { return "Revise las linea del Volcado."; } public static string G_STR_MENSAJES_DOCUMENTO_VOLCADO_REVISARLINEASVOLCADO() { return "Revise las linea del Volcado."; }
public static string G_STR_MENSAJES_DOCUMENTO_VOLCADO_VALOR_CERO_NOSEVUELCA() { return "No se vuelca un valor 0."; } public static string G_STR_MENSAJES_DOCUMENTO_VOLCADO_VALOR_CERO_NOSEVUELCA() { return "No se vuelca un valor 0."; }
public static string G_STR_ESPERANDO_ENVIANDO_MENSAJES() { return "Enviando mensajes , espere por favor ..."; } public static string G_STR_ESPERANDO_ENVIANDO_MENSAJES() { return "Enviando mensajes , espere por favor ..."; }
public static string G_STR_ESPERANDO_GENERA_FACTURA_E() { return "Generando Facturas , espere por favor ..."; }
public static string G_STR_VALIDACION_HAYDOCUMENTOSCERRADOS_POSTERIORES() { return "Hay documentos cerrados poesteriores a este, por favor reviselos."; } public static string G_STR_VALIDACION_HAYDOCUMENTOSCERRADOS_POSTERIORES() { return "Hay documentos cerrados poesteriores a este, por favor reviselos."; }
#endregion #endregion

View File

@ -8,7 +8,7 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
{ {
public class INTERNO_Correcciones_Factura_E_Modelo public class INTERNO_Correcciones_Factura_E_Modelo
{ {
public int NumeroFactura { get; set; }//numero factura que rectifica public long NumeroFactura { get; set; }//numero factura que rectifica
public String SerieDelegacion { get; set; }//serie de la factura que rectifica public String SerieDelegacion { get; set; }//serie de la factura que rectifica
public string RazonCode { get; set; }//(ReasonDescription) public string RazonCode { get; set; }//(ReasonDescription)
public DateTime Inicio { get; set; } public DateTime Inicio { get; set; }

View File

@ -20,7 +20,7 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
public string Identificador { get; set; }//BatchIdentifier public string Identificador { get; set; }//BatchIdentifier
public string Moneda { get; set;} public string Moneda { get; set;}
public int NumeroFactura { get; set;} public long NumeroFactura { get; set;}
public String SerieDelegacion { get; set; } public String SerieDelegacion { get; set; }
public bool FacturaOriginal { get; set; } public bool FacturaOriginal { get; set; }
INTERNO_Correcciones_Factura_E_Modelo Correcciones { get; set; } INTERNO_Correcciones_Factura_E_Modelo Correcciones { get; set; }
@ -31,14 +31,14 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
INTERNO_Impuestos_Factura_E_modelo Impuesto { get; set; } INTERNO_Impuestos_Factura_E_modelo Impuesto { get; set; }
//resumen----------------------------------------- //resumen-----------------------------------------
public double TotalBruto { get; set; } public decimal TotalBruto { get; set; }
public double TotalDescuento { get; set; } public decimal TotalDescuento { get; set; }
public double TotalBase { get; set; } public decimal TotalBase { get; set; }
public double TotalImpuestos { get; set; } public decimal TotalImpuestos { get; set; }
public float TotalFactura { get; set; } public decimal TotalFactura { get; set; }
public float TotalPendiente { get; set; } public decimal TotalPendiente { get; set; }
public float TotalEjecutable { get; set; } public decimal TotalEjecutable { get; set; }
public float TotalAnticipo { get; set; } public decimal TotalAnticipo { get; set; }
//elementos factura------------------------------ //elementos factura------------------------------
INTERNO_Item_Factura_E_modelo[] Items { get; set; } INTERNO_Item_Factura_E_modelo[] Items { get; set; }
@ -223,7 +223,7 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
} }
#endregion #endregion
#region Metodos #region Metodos
string importarXML(string path) public string importarXML(string path)
{ {
error = ""; error = "";
string res = null; string res = null;
@ -256,7 +256,7 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
return res; return res;
} }
string exportarXML(string path) public string exportarXML(string path)
{ {
error = ""; error = "";
string res = null; string res = null;
@ -570,12 +570,18 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
nod = doc.CreateElement(string.Empty, FACTURA_E_TeleFax_NAME, string.Empty); nod = doc.CreateElement(string.Empty, FACTURA_E_TeleFax_NAME, string.Empty);
nod.InnerText = dat.Fax; nod.InnerText = dat.Fax;
nbase.AppendChild(nod); nbase.AppendChild(nod);
if (dat.Web != null)
{
nod = doc.CreateElement(string.Empty, FACTURA_E_WebAddress_NAME, string.Empty); nod = doc.CreateElement(string.Empty, FACTURA_E_WebAddress_NAME, string.Empty);
nod.InnerText = dat.Web; nod.InnerText = dat.Web;
nbase.AppendChild(nod); nbase.AppendChild(nod);
}
if (dat.Email != null)
{
nod = doc.CreateElement(string.Empty, FACTURA_E_ElectronicMail_NAME, string.Empty); nod = doc.CreateElement(string.Empty, FACTURA_E_ElectronicMail_NAME, string.Empty);
nod.InnerText = dat.Email; nod.InnerText = dat.Email;
nbase.AppendChild(nod); nbase.AppendChild(nod);
}
nodo.AppendChild(nbase); nodo.AppendChild(nbase);
} }
@ -921,18 +927,15 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
{ {
return t.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); return t.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
} }
string toStr(int t) string toStr(long t)
{ {
return t.ToString(); return t.ToString();
} }
string toStr(float t) string toStr(decimal t)
{
return t.ToString();
}
string toStr(double t)
{ {
return t.ToString(); return t.ToString();
} }
#endregion #endregion
#region LecturaXML #region LecturaXML
private string leeXML(XmlNode factura) private string leeXML(XmlNode factura)
@ -1001,12 +1004,12 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
if (str == null) if (str == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
Identificador = str; Identificador = str;
float? dat = getFloat(cab, FACTURA_E_BATCH_NAME + "/" + FACTURA_E_TotalInvoicesAmount_NAME+ "/"+ FACTURA_E_TotalAmount_NAME); decimal? dat = getdecimal(cab, FACTURA_E_BATCH_NAME + "/" + FACTURA_E_TotalInvoicesAmount_NAME+ "/"+ FACTURA_E_TotalAmount_NAME);
if (dat == null) if (dat == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
TotalFactura = dat.Value; TotalFactura = dat.Value;
dat = getFloat(cab, FACTURA_E_BATCH_NAME + "/" + FACTURA_E_TotalOutstandingAmount_NAME + "/" + FACTURA_E_TotalAmount_NAME); dat = getdecimal(cab, FACTURA_E_BATCH_NAME + "/" + FACTURA_E_TotalOutstandingAmount_NAME + "/" + FACTURA_E_TotalAmount_NAME);
if (dat == null) if (dat == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
TotalPendiente = dat.Value; TotalPendiente = dat.Value;
@ -1174,12 +1177,12 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.Cantidad = i.Value; dat.Cantidad = i.Value;
float? f = getFloat(node, FACTURA_E_UnitPriceWithoutTax_NAME); decimal? f = getdecimal(node, FACTURA_E_UnitPriceWithoutTax_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.Precio = f.Value; dat.Precio = f.Value;
f = getFloat(node, FACTURA_E_TotalCost_NAME); f = getdecimal(node, FACTURA_E_TotalCost_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.Total = f.Value; dat.Total = f.Value;
@ -1189,16 +1192,16 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
if (str == null) if (str == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.DescuentoRazon = str; dat.DescuentoRazon = str;
f = getFloat(node, FACTURA_E_DiscountsAndRebates_NAME + "/" + FACTURA_E_Discount_NAME + "/" + FACTURA_E_DiscountRate_NAME); f = getdecimal(node, FACTURA_E_DiscountsAndRebates_NAME + "/" + FACTURA_E_Discount_NAME + "/" + FACTURA_E_DiscountRate_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.DescuentoPorcentaje = f.Value; dat.DescuentoPorcentaje = f.Value;
f = getFloat(node, FACTURA_E_DiscountsAndRebates_NAME + "/" + FACTURA_E_Discount_NAME + "/" + FACTURA_E_DiscountAmount_NAME); f = getdecimal(node, FACTURA_E_DiscountsAndRebates_NAME + "/" + FACTURA_E_Discount_NAME + "/" + FACTURA_E_DiscountAmount_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.Descuentoimporte = f.Value; dat.Descuentoimporte = f.Value;
f = getFloat(node, FACTURA_E_GrossAmount_NAME); f = getdecimal(node, FACTURA_E_GrossAmount_NAME);
if (str == null) if (str == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.ImporteBruto = f.Value; dat.ImporteBruto = f.Value;
@ -1230,42 +1233,42 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
} }
private string getTotal( XmlNode node) private string getTotal( XmlNode node)
{ {
float? f = getFloat(node, FACTURA_E_TotalGrossAmount_NAME); decimal? f = getdecimal(node, FACTURA_E_TotalGrossAmount_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
TotalBruto = f.Value; TotalBruto = f.Value;
f = getFloat(node, FACTURA_E_TotalGeneralDiscounts_NAME); f = getdecimal(node, FACTURA_E_TotalGeneralDiscounts_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
TotalDescuento = f.Value; TotalDescuento = f.Value;
f = getFloat(node, FACTURA_E_TotalGrossAmountBeforeTaxes_NAME); f = getdecimal(node, FACTURA_E_TotalGrossAmountBeforeTaxes_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
TotalBase = f.Value; TotalBase = f.Value;
f = getFloat(node, FACTURA_E_TotalTaxOutputs_NAME); f = getdecimal(node, FACTURA_E_TotalTaxOutputs_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
TotalImpuestos = f.Value; TotalImpuestos = f.Value;
f = getFloat(node, FACTURA_E_InvoiceTotals_NAME); f = getdecimal(node, FACTURA_E_InvoiceTotals_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
if (TotalFactura == f.Value) if (TotalFactura == f.Value)
return "Valores de total factura no coinciden: " + FACTURA_E_InvoiceTotals_NAME; return "Valores de total factura no coinciden: " + FACTURA_E_InvoiceTotals_NAME;
f = getFloat(node, FACTURA_E_TotalOutstandingAmount_NAME); f = getdecimal(node, FACTURA_E_TotalOutstandingAmount_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
TotalPendiente = f.Value; TotalPendiente = f.Value;
f = getFloat(node, FACTURA_E_TotalPaymentsOnAccount_NAME); f = getdecimal(node, FACTURA_E_TotalPaymentsOnAccount_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
TotalAnticipo = f.Value; TotalAnticipo = f.Value;
f = getFloat(node, FACTURA_E_TotalExecutableAmount_NAME); f = getdecimal(node, FACTURA_E_TotalExecutableAmount_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
TotalEjecutable = f.Value; TotalEjecutable = f.Value;
@ -1285,16 +1288,16 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.Tipo = i.Value; dat.Tipo = i.Value;
float? f = getFloat(node, FACTURA_E_TaxRate_NAME); decimal? f = getdecimal(node, FACTURA_E_TaxRate_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.Porcentaje = f.Value; dat.Porcentaje = f.Value;
f = getFloat(node, FACTURA_E_TaxableBase_NAME+"/"+ FACTURA_E_TotalAmount_NAME); f = getdecimal(node, FACTURA_E_TaxableBase_NAME+"/"+ FACTURA_E_TotalAmount_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.Base = f.Value; dat.Base = f.Value;
f = getFloat(node, FACTURA_E_TaxAmount_NAME + "/" + FACTURA_E_TotalAmount_NAME); f = getdecimal(node, FACTURA_E_TaxAmount_NAME + "/" + FACTURA_E_TotalAmount_NAME);
if (f == null) if (f == null)
return "Estructura invalida" + error; return "Estructura invalida" + error;
dat.Importe = f.Value; dat.Importe = f.Value;
@ -1527,15 +1530,15 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
return res; return res;
} }
private float? getFloat(XmlNode node, string xpath) private decimal? getdecimal(XmlNode node, string xpath)
{ {
float? res = null; decimal? res = null;
var str = getText(node, xpath); var str = getText(node, xpath);
if(str!=null) if(str!=null)
{ {
try try
{ {
res = float.Parse(str); res = decimal.Parse(str);
} }
catch catch
{ {

View File

@ -8,9 +8,9 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
{ {
public class INTERNO_Impuestos_Factura_E_modelo public class INTERNO_Impuestos_Factura_E_modelo
{ {
public float Porcentaje { get; set; } public decimal Porcentaje { get; set; }
public int Tipo { get; set; } public long Tipo { get; set; }
public float Base { get; set; } public decimal Base { get; set; }
public double Importe { get; set; } public decimal Importe { get; set; }
} }
} }

View File

@ -12,15 +12,15 @@ namespace Exferia_Aplicacion.Modelos_Factura_E
public string CodigoArticulo { get; set; } public string CodigoArticulo { get; set; }
public DateTime Fecha { get; set; } public DateTime Fecha { get; set; }
public int Cantidad { get; set; } public long Cantidad { get; set; }
public string Descripcion { get; set; } public string Descripcion { get; set; }
public double Precio { get; set; } public decimal Precio { get; set; }
public double Total { get; set; } public decimal Total { get; set; }
public string DescuentoRazon { get; set; } public string DescuentoRazon { get; set; }
public double DescuentoPorcentaje { get; set; } public decimal DescuentoPorcentaje { get; set; }
public double Descuentoimporte { get; set; } public decimal Descuentoimporte { get; set; }
public double ImporteBruto { get; set; }//despues de descuentos public decimal ImporteBruto { get; set; }//despues de descuentos
public string Adicional { get; set; } public string Adicional { get; set; }
public DateTime FechaAlbaran { get; set; } public DateTime FechaAlbaran { get; set; }
} }

View File

@ -11299,7 +11299,96 @@ namespace Exferia_Ventas._3_Vistas.Controladoras
} }
} }
#endregion #endregion
#region Proceso Factura electronica
public void Proceso_FacturaE()
{
try
{
//Bloquear el formulario para que no se pueda hacer nada hasta que termine
g_frm_P_FacturaCabecera.Enabled = false;
//Mostrar la pantalla de espera
g_frm_PE_Esperando_BarraProgreso = new PE_Esperando_BarraProgreso(Mensajes.G_STR_ESPERANDO_GENERA_FACTURA_E());
// Si la tarea asincrona esta en marcha la paro
if (g_obj_TareaAsincrona_ProcesoEnviarMensajes != null)
{
while (g_obj_TareaAsincrona_ProcesoEnviarMensajes.IsBusy)
Application.DoEvents();
}
else
{
g_obj_TareaAsincrona_ProcesoEnviarMensajes = new BackgroundWorker();
g_obj_TareaAsincrona_ProcesoEnviarMensajes.DoWork += new DoWorkEventHandler(TareaAsincrona_ProcesoFacturaE_DoWork);
//g_obj_TareaAsincrona_ProcesoEnviarMensajes.ProgressChanged += new ProgressChangedEventHandler(TareaAsincrona_ProcesoEnviarMensajes_ProgressChanged);
g_obj_TareaAsincrona_ProcesoEnviarMensajes.RunWorkerCompleted += new RunWorkerCompletedEventHandler(TareaAsincrona_ProcesoFacturaE_Completed);
g_obj_TareaAsincrona_ProcesoEnviarMensajes.WorkerReportsProgress = false;
}
//(Tarea Asincrona) ##################################################################
g_obj_TareaAsincrona_ProcesoEnviarMensajes.RunWorkerAsync();
//#################################################################################################
g_frm_PE_Esperando_BarraProgreso.Show();
}
catch (Exception ex)
{
g_frm_P_FacturaCabecera.Enabled = true;
if (g_frm_PE_Esperando_BarraProgreso != null)
{
g_frm_PE_Esperando_BarraProgreso.Close();
g_frm_PE_Esperando_BarraProgreso = null;
}
throw new Control_Errores("", ex, nameof(P_FacturaCabecera_Procesos_Controladora) + "/" + nameof(Proceso_FacturaE), true);
}
}
private void TareaAsincrona_ProcesoFacturaE_DoWork(object sender, DoWorkEventArgs e)
{
//G_MDL_TIPOEMAIL_FACTURAS
try
{
INTERNO_ERP_ValoresGenerales_Listado_Modelo _ERP_ValoresGenerales = Obtener_ERP_ValoresGenerales();
var resul = Funciones_Ventas.GenerarFacturaElectronica( g_mdl_INTERNO_VTA_FacturasCabecera_Modelo, "c:\temp\factura.xml");
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_FacturaCabecera_Procesos_Controladora) + "/" + nameof(TareaAsincrona_ProcesoFacturaE_DoWork));
}
}
private void TareaAsincrona_ProcesoFacturaE_Completed(object sender, RunWorkerCompletedEventArgs e)
{
try
{
if (g_frm_PE_Esperando_BarraProgreso != null)
{
g_frm_PE_Esperando_BarraProgreso.Close();
g_frm_PE_Esperando_BarraProgreso = null;
}
INTERNO_ValorDevuelto_Modelo mdl_ValorDevuelto_Modelo_Resultado = (INTERNO_ValorDevuelto_Modelo)e.Result;
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_FacturaCabecera_Procesos_Controladora) + "/" + nameof(TareaAsincrona_ProcesoFacturaE_Completed));
}
finally
{
//Desbloquear el Formulario
g_frm_P_FacturaCabecera.Enabled = true;
}
}
#endregion
#region Enviar Mensajes #region Enviar Mensajes
public void Proceso_EnviarMensajes() public void Proceso_EnviarMensajes()
{ {

View File

@ -234,7 +234,7 @@ namespace Exferia_Ventas._3_Vistas
ex_btn_P_FacturaCabecera_RecalcularResumen.Exferia_Button_Bloqueable = false; ex_btn_P_FacturaCabecera_RecalcularResumen.Exferia_Button_Bloqueable = false;
ex_btn_P_FacturaCabecera_EnviarMensajes.Exferia_Button_Bloqueable = false; ex_btn_P_FacturaCabecera_EnviarMensajes.Exferia_Button_Bloqueable = false;
ex_btn_P_FacturaCabecera_FacturaE.Exferia_Button_Bloqueable = false;
//Anexo //Anexo
ex_btn_P_FacturaCabecera_Anexo_Actualizar.Exferia_Button_Bloqueable = false; ex_btn_P_FacturaCabecera_Anexo_Actualizar.Exferia_Button_Bloqueable = false;
ex_txt_P_FacturaCabecera_Anexo_NumeroPedidoCliente.Exferia_TextBox_Bloqueable = false; ex_txt_P_FacturaCabecera_Anexo_NumeroPedidoCliente.Exferia_TextBox_Bloqueable = false;
@ -4111,7 +4111,7 @@ namespace Exferia_Ventas._3_Vistas
private void ex_btn_P_FacturaCabecera_FacturaE_Click(object sender, EventArgs e) private void ex_btn_P_FacturaCabecera_FacturaE_Click(object sender, EventArgs e)
{ {
g_obj_Controladora.Proceso_FacturaE();
} }
} }
} }

View File

@ -1,6 +1,7 @@
using Exferia_Aplicacion.Calculos; using Exferia_Aplicacion.Calculos;
using Exferia_Aplicacion.Calculos.VentasCompras; using Exferia_Aplicacion.Calculos.VentasCompras;
using Exferia_Aplicacion.General; using Exferia_Aplicacion.General;
using Exferia_Aplicacion.Modelos_Factura_E;
using Exferia_Aplicacion.Modelos_Generales; using Exferia_Aplicacion.Modelos_Generales;
using Exferia_Aplicacion.Modelos_Informes; using Exferia_Aplicacion.Modelos_Informes;
using Exferia_EntityFramework; using Exferia_EntityFramework;
@ -946,6 +947,95 @@ namespace Exferia_Ventas.General
return mdl_INTERNO_ValorDevuelto_Modelo; return mdl_INTERNO_ValorDevuelto_Modelo;
} }
#endregion #endregion
public static INTERNO_ValorDevuelto_Modelo GenerarFacturaElectronica( VTA_FacturasCabecera factura, string path)
{
INTERNO_ValorDevuelto_Modelo res = new INTERNO_ValorDevuelto_Modelo();
res.TodoCorrecto = true;
try
{
var empresaVendedor=Datos_Generales.GEN_Empresas_Obtener_Modelo_Por_Id(factura.idEmpresa);
var empresaComprador = Datos_Generales.GEN_Empresas_Obtener_Modelo_Por_Id(factura.MAE_Clientes.idEmpresa);
INTERNO_Factura_e_Modelo factura_e = new INTERNO_Factura_e_Modelo();
var idEmpresa = new List<long>();
idEmpresa.Add(factura.idEmpresa);
var idEmpresacomprador = new List<long>();
idEmpresa.Add(empresaComprador.id);
//conseguir direcciones--------------
var direcliente = Datos_Generales.GEN_Direcciones_Obtener_Modelo_Listado_Por_IdsEmpresaTipoDireccion(idEmpresacomprador, "2", true, true, true, true, true).FirstOrDefault();// factura.MAE_Clientes.GEN_Direcciones.FirstOrDefault(e => int.Parse(e.tipoDireccion) == 2);
var direEmpresa = Datos_Generales.GEN_Direcciones_Obtener_Modelo_Listado_Por_IdsEmpresaTipoDireccion(idEmpresa, "2", true, true, true, true, true).FirstOrDefault();
//delegacion
var delegacion = Datos_Generales.GEN_Delegaciones_Obtener_Modelo_Por_Id(factura.idDelegacion);
var albaranes = factura.VTA_AlbaranesFacturasLineas;//lineas factura
//rellenar datos
factura_e.Identificador = factura.MAE_Clientes.cif + factura.numeroFactura + factura.GEN_Delegaciones.codigo;
factura_e.TotalFactura = factura.total_Final;
factura_e.TotalPendiente = factura.total_Final;
//vendedor--------------------------------------------------------------------------------------------------
factura_e.Vendedor = new INTERNO_Vendedor_Factura_E_modelo();
if ('0' >= empresaVendedor.nif[0] && '9' <= empresaVendedor.nif[0])
factura_e.Vendedor.Tipo = "F";
else
factura_e.Vendedor.Tipo = "J";
factura_e.Vendedor.IdImpuestos = (direcliente.idPais == direEmpresa.idPais ? "" : direEmpresa.GEN_Paises.codigo_ISO2D) + empresaVendedor.nif;
factura_e.Vendedor.RazonSocial = empresaVendedor.razonSocial;
factura_e.Vendedor.NombreComercial = empresaVendedor.descripcion;
factura_e.Vendedor.Direccion = direEmpresa.nombreVia+", "+direcliente.numeroCasa;
factura_e.Vendedor.CP = direEmpresa.codigoPostal;
factura_e.Vendedor.Poblacion = direEmpresa.GEN_Poblaciones.descripcion;
factura_e.Vendedor.Provincia = direEmpresa.GEN_Provincias.descripcion;
factura_e.Vendedor.Pais = direEmpresa.GEN_Paises.descripcion;
factura_e.Vendedor.Tlf = empresaVendedor.telefonoOficina;
factura_e.Vendedor.Fax = empresaVendedor.telefonoFax;
factura_e.Vendedor.Web = null;
factura_e.Vendedor.Email = empresaVendedor.email;
//cliente--------------------------------------------------------------------------------------------------
factura_e.Comprador = new INTERNO_Comprador_Factura_E_modelo();
if ('0' >= empresaComprador.nif[0] && '9' <= empresaComprador.nif[0])
factura_e.Comprador.Tipo = "F";
else
factura_e.Comprador.Tipo = "J";
factura_e.Comprador.IdImpuestos = (direcliente.idPais == direEmpresa.idPais ? "" : direcliente.GEN_Paises.codigo_ISO2D) + empresaComprador.nif;
factura_e.Comprador.RazonSocial = empresaComprador.razonSocial;
factura_e.Comprador.NombreComercial = empresaComprador.descripcion;
factura_e.Comprador.Direccion = direcliente.nombreVia + ", " + direcliente.numeroCasa;
factura_e.Comprador.CP = direcliente.codigoPostal;
factura_e.Comprador.Poblacion = direcliente.GEN_Poblaciones.descripcion;
factura_e.Comprador.Provincia = direcliente.GEN_Provincias.descripcion;
factura_e.Comprador.Pais = direcliente.GEN_Paises.descripcion;
factura_e.Comprador = null;
//datos factura----------------------
factura_e.NumeroFactura = factura.numeroFactura;
factura_e.SerieDelegacion = delegacion.codigo;
factura_e.FacturaOriginal = true;
//correcciones--------------------
factura_e.Fecha = factura.fecha;
//exporta---------------------------------------------------------------------------------------------------
string resul =factura_e.exportarXML(path);
if(resul!=null)
{
res.TodoCorrecto = false;
Control_Errores.Errores_Log(resul, nameof(Funciones_Ventas) + "/" + nameof(GenerarFacturaElectronica));
}
} }
catch (Exception ex)
{
res.TodoCorrecto = false;
Control_Errores.Errores_Log("", ex, nameof(Funciones_Ventas) + "/" + nameof(GenerarFacturaElectronica));
}
return res;
}
}
} }