Soporte en fluctuacion con pago de nc

This commit is contained in:
Raul Pimienta
2019-08-29 17:21:47 -07:00
parent b09185499b
commit 2cbeb50aac

View File

@@ -11183,6 +11183,7 @@ Partial Class Ventas
Dim ObjConta As New ClsContabilidad Dim ObjConta As New ClsContabilidad
Dim ObjVenta As New ClsVentas(ObjConta.IniciaTransacSQL()) Dim ObjVenta As New ClsVentas(ObjConta.IniciaTransacSQL())
Dim ObjIE As New ClsBancos(ObjConta.IniciaTransacSQL())
Dim ObjContpaq As ClsContPAQi = Nothing Dim ObjContpaq As ClsContPAQi = Nothing
Dim CvePrepoliza As Integer Dim CvePrepoliza As Integer
@@ -11215,11 +11216,16 @@ Partial Class Ventas
' FechaMaxima = "01/01/2018".ToDate ' FechaMaxima = "01/01/2018".ToDate
'End If 'End If
CvePrepoliza = ObjConta.AddPrePolizas("Ventas/Anticipos", CvePlantillaPoliza, TxtTotal.Text.ToDecimal, TxtTotal.Text.ToDecimal, DdlMoneda.SelectedValue.ToEntero, TxtFechaAnticipoCliente.Text.ToDate, String.Format("{0} {1} {2}-{3}", If(EsAnticipo2017Jam, "Aplicación Anticipo 2017", ""), NombreCliente, Serie, TxtFolio.Text), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) CvePrepoliza = ObjConta.AddPrePolizas("Ventas/Anticipos", CvePlantillaPoliza, TxtTotal.Text.ToDecimal, TxtTotal.Text.ToDecimal, DdlMoneda.SelectedValue.ToEntero, TxtFechaAnticipoCliente.Text.ToDate, String.Format("{0} {1} {2}-{3}", If(EsAnticipo2017Jam, "Aplicación Anticipo 2017", ""), NombreCliente, Serie, TxtFolio.Text), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If CvePrepoliza > 0 Then If CvePrepoliza > 0 Then
Dim tipoCambioPago As Decimal = 1 Dim tipoCambioPago As Decimal = 1
Dim tipoCambioVenta As Decimal = 1 Dim tipoCambioVenta As Decimal = 1
Dim tipoCambioVentaValuacion As Decimal = 1
Dim PorcentajePago As Decimal = 100 Dim PorcentajePago As Decimal = 100
Dim dtConceptos As DataTable = Nothing Dim dtConceptos As DataTable = Nothing
Dim CveMonedaVenta = DdlMoneda.SelectedValue.ToEntero Dim CveMonedaVenta = DdlMoneda.SelectedValue.ToEntero
@@ -11243,21 +11249,42 @@ Partial Class Ventas
For Each gvr As GridViewRow In GVAnticipos.Rows For Each gvr As GridViewRow In GVAnticipos.Rows
If gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked Then If gvr.FCCheckBox("Chk" & gvr.RowIndex).Checked Then
Dim FechaUltimaFluctuacion As Date = MinFecha
Dim TipoCambioFluctuacion As Decimal = 1
If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then
If ObjIE.DtResultados.Rows.Count > 0 Then
Dim tFecha As Date = gvr.DataKey("Fecha").ToDate
Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day)
Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC")
If drr IsNot Nothing Then
FechaUltimaFluctuacion = drr("Fecha").ToString.ToDate
TipoCambioFluctuacion = drr("TipoCambio").ToString.ToDecimal
End If
End If
End If
If DdlMoneda.SelectedValue.ToEntero = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos If DdlMoneda.SelectedValue.ToEntero = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en Pesos y se va a pagar en Pesos
tipoCambioPago = 1 tipoCambioPago = 1
tipoCambioVenta = 1 tipoCambioVenta = 1
tipoCambioVentaValuacion = 1
PorcentajePago = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("Original").ToDecimal PorcentajePago = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("Original").ToDecimal
ElseIf DdlMoneda.SelectedValue.ToEntero = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en Dolares y se va a pagar en Pesos ElseIf DdlMoneda.SelectedValue.ToEntero = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en Dolares y se va a pagar en Pesos
tipoCambioPago = gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal tipoCambioPago = gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal
tipoCambioVenta = TxtTipoCambio.Text.ToDecimal tipoCambioVenta = TxtTipoCambio.Text.ToDecimal
tipoCambioVentaValuacion = If(TxtFecha.Text.ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, TxtTipoCambio.Text.ToDecimal)
PorcentajePago = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal) / gvr.DataKey("Original").ToDecimal PorcentajePago = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal) / gvr.DataKey("Original").ToDecimal
ElseIf DdlMoneda.SelectedValue.ToEntero = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES ElseIf DdlMoneda.SelectedValue.ToEntero = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES
tipoCambioPago = gvr.DataKey("TipoCambio").ToString.ToDecimal tipoCambioPago = gvr.DataKey("TipoCambio").ToString.ToDecimal
tipoCambioVenta = TxtTipoCambio.Text.ToDecimal tipoCambioVenta = TxtTipoCambio.Text.ToDecimal
tipoCambioVentaValuacion = If(TxtFecha.Text.ToDate < FechaUltimaFluctuacion, TipoCambioFluctuacion, TxtTipoCambio.Text.ToDecimal)
PorcentajePago = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("Original").ToDecimal PorcentajePago = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal / gvr.DataKey("Original").ToDecimal
ElseIf DdlMoneda.SelectedValue.ToEntero = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES ElseIf DdlMoneda.SelectedValue.ToEntero = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
tipoCambioPago = gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal tipoCambioPago = gvr.FCTextBox("TxtTC" & gvr.RowIndex).Text.ToDecimal
tipoCambioVenta = 1 tipoCambioVenta = 1
tipoCambioVentaValuacion = 1
PorcentajePago = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal) / gvr.DataKey("Original").ToDecimal PorcentajePago = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal) / gvr.DataKey("Original").ToDecimal
End If End If
@@ -11284,17 +11311,17 @@ Partial Class Ventas
importeMX = importeMovimiento importeMX = importeMovimiento
ElseIf DdlMoneda.SelectedValue.ToEntero = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then ElseIf DdlMoneda.SelectedValue.ToEntero = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 1 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMX = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioVenta importeMX = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioVentaValuacion
ElseIf DdlMoneda.SelectedValue.ToEntero = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ElseIf DdlMoneda.SelectedValue.ToEntero = 2 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMX = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioVenta importeMX = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioVentaValuacion
ElseIf DdlMoneda.SelectedValue.ToEntero = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then ElseIf DdlMoneda.SelectedValue.ToEntero = 1 AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal importeMovimiento = gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal
importeMX = importeMovimiento importeMX = importeMovimiento
End If End If
importeMovimiento = Math.Round(importeMovimiento, 2) importeMovimiento = Math.Round(importeMovimiento, 2)
importeMX = Math.Round(importeMX, 2) importeMX = Math.Round(importeMX, 2)
TipoCambioGeneral = tipoCambioVenta TipoCambioGeneral = tipoCambioVentaValuacion
If CveMonedaVenta = 1 Then If CveMonedaVenta = 1 Then
IdCtaContable = IdCtaContClientes IdCtaContable = IdCtaContClientes
@@ -11315,7 +11342,7 @@ Partial Class Ventas
CveCuentaContabilizacion = 0 CveCuentaContabilizacion = 0
End If End If
If Not ObjConta.AddPrePolizasDetalle(CvePrepoliza, TipoMovimiento, 0, Concepto, 207, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Math.Round(importeMovimiento * tipoCambioVenta - importeMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioVenta) Then If Not ObjConta.AddPrePolizasDetalle(CvePrepoliza, TipoMovimiento, 0, Concepto, 207, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, ImporteMX:=Math.Round(importeMovimiento * tipoCambioVenta - importeMovimiento, 2, MidpointRounding.AwayFromZero), ImporteME:=importeMovimiento, CveCuenta:=CveCuenta, TipoCambio:=tipoCambioVentaValuacion) Then
ErrorConta = True ErrorConta = True
End If End If
@@ -11543,13 +11570,14 @@ Partial Class Ventas
If CveMonedaVenta <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then If CveMonedaVenta <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then
IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria IdCtaContable = UsuarioActual.Empresa.IdCuentaGananciaCambiaria
CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria CveCuenta = UsuarioActual.Empresa.CveCuentaGananciaCambiaria
Dim TipoCambioGanancia As Decimal = If(Not (gvr.DataKey("CveIE").ToString.ToEntero > 0 AndAlso gvr.DataKey("CveConceptoContable").ToString().ToEntero = 66), tipoCambioVentaValuacion, tipoCambioVenta)
If tipoCambioPago > tipoCambioVenta AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then If tipoCambioPago > TipoCambioGanancia AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
importeMovimiento = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioPago) - (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioVenta) 'Añadimos la diferencia de ganancia en la venta importeMovimiento = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioPago) - (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * TipoCambioGanancia) 'Añadimos la diferencia de ganancia en la venta
importeMovimiento = Math.Abs(Math.Round(importeMovimiento, 2)) importeMovimiento = Math.Abs(Math.Round(importeMovimiento, 2))
importeMX = importeMovimiento importeMX = importeMovimiento
End If End If
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioVenta, tipoCambioPago) Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioGanancia, tipoCambioPago)
TipoCambioGeneral = TCImpuestos TipoCambioGeneral = TCImpuestos
Else Else
importeMovimiento = 0 importeMovimiento = 0
@@ -11558,13 +11586,14 @@ Partial Class Ventas
If CveMonedaVenta <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then If CveMonedaVenta <> 1 OrElse gvr.DataKey("CveMoneda").ToEntero <> 1 Then
IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria IdCtaContable = UsuarioActual.Empresa.IdCuentaPerdidaCambiaria
CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria CveCuenta = UsuarioActual.Empresa.CveCuentaPerdidaCambiaria
Dim TipoCambioPerdida As Decimal = If(Not (gvr.DataKey("CveIE").ToString.ToEntero > 0 AndAlso gvr.DataKey("CveConceptoContable").ToString().ToEntero = 66), tipoCambioVentaValuacion, tipoCambioVenta)
If tipoCambioPago < tipoCambioVenta AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then If tipoCambioPago < TipoCambioPerdida AndAlso gvr.DataKey("CveMoneda").ToEntero = 2 Then
importeMovimiento = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioVenta) - (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta importeMovimiento = (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * TipoCambioPerdida) - (gvr.FCTextBox("TxtAnticipo" & gvr.RowIndex).Text.ToDecimal * tipoCambioPago) 'Añadimos la diferencia de perdida en la venta
importeMovimiento = Math.Abs(Math.Round(importeMovimiento, 2)) importeMovimiento = Math.Abs(Math.Round(importeMovimiento, 2))
importeMX = importeMovimiento importeMX = importeMovimiento
End If End If
Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, tipoCambioVenta, tipoCambioPago) Dim TCImpuestos As Decimal = If(FuncionalidadFluctuacionImpuestos, TipoCambioPerdida, tipoCambioPago)
TipoCambioGeneral = TCImpuestos TipoCambioGeneral = TCImpuestos
Else Else
importeMovimiento = 0 importeMovimiento = 0
@@ -11627,6 +11656,8 @@ Partial Class Ventas
End If End If
ObjConta.Dispose() ObjConta.Dispose()
ObjIE.Dispose()
Else Else
'cuando no se ha registrado la venta 'cuando no se ha registrado la venta
@@ -21204,6 +21235,26 @@ Partial Class Ventas
TrFolioFiscal.Visible = False TrFolioFiscal.Visible = False
TxtFecha.Text = Now.ToShortDateString() TxtFecha.Text = Now.ToShortDateString()
TipoCambioFactura = TxtTipoCambio.Text.ToDecimal TipoCambioFactura = TxtTipoCambio.Text.ToDecimal
If DdlMoneda.SelectedValue.ToEntero > 1 Then
Dim ObjIE As New ClsBancos
If ObjIE.GetFluctuacionesBitacora(UsuarioActual.CveEmpresa) Then
If ObjIE.DtResultados.Rows.Count > 0 Then
Dim tFecha As Date = TxtFecha.Text.ToDate
Dim Fecha As String = String.Format("{0}/{1}/{2}", tFecha.Year, tFecha.Month, tFecha.Day)
Dim drr As DataRow = ObjIE.DtResultados.FiltroPrimero("Fecha < #" & Fecha & "#", "Fecha DESC")
If drr IsNot Nothing Then
TipoCambioFactura = drr("TipoCambio").ToString.ToDecimal
End If
End If
End If
ObjIE.Dispose()
Else
TipoCambioFactura = 1
End If
TxtTipoCambio.Text = GlobalTipoCambio(Now).ToString TxtTipoCambio.Text = GlobalTipoCambio(Now).ToString
DivEstatusFac.Visible = False DivEstatusFac.Visible = False