Compras creditos, ret iva ret isr al actualizar ps, tipo de cambio al actualizar compra

This commit is contained in:
Oscar Irigoyen
2023-05-22 22:01:30 -07:00
parent 3eaa55a62e
commit 2004bb6db4
2 changed files with 59 additions and 29 deletions

View File

@@ -3598,25 +3598,24 @@
<div class="col-md-2" style="text-align: left;">
<asp:CheckBox ID="ChkIEPS" runat="server" Text="IEPS" Visible="false" />
</div>
<div class="col-md-3" style="text-align: center; margin-top: 5px">
<div class="col-md-2" style="text-align: center; margin-top: 5px">
<asp:Label runat="server" ID="LbImporte" />
</div>
<div class="col-md-4">
<div class="col-md-7">
<asp:DropDownList ID="DdlConceptoIEPS" runat="server" CssClass="form-control input-sm select2me" AppendDataBoundItems="true" DataTextField="PS" DataValueField="CvePS" Width="100px" ValidationGroup="GrpAgregar" Visible="false"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVConceptoIEPS" runat="server" ControlToValidate="DdlConceptoIEPS" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />Es necesario <b>seleccionar un concepto, </b>por favor ingréselo." InitialValue="-1" ValidationGroup="GrpAgregar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEConceptoIEPS" runat="server" HighlightCssClass="vco" TargetControlID="RFVConceptoIEPS" Width="300px" BehaviorID="VCEConceptoIEPS"></ajax:ValidatorCalloutExtender>
</div>
<div class="col-md-5"></div>
</div>
</div>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-2" style="text-align: left; width: 140px">
<asp:CheckBox ID="ChkOtrosI" runat="server" Text="Otros Impuestos" Visible="false" />
</div>
<div class="col-md-3" style="text-align: center; margin-top: 5px">
<div class="col-md-2" style="text-align: center; margin-top: 5px">
<asp:Label runat="server" ID="LbImporte2" />
</div>
<div class="col-md-4">
<div class="col-md-7">
<asp:DropDownList ID="DdlConceptoOI" runat="server" CssClass="form-control input-sm select2me" AppendDataBoundItems="true" DataTextField="PS" DataValueField="CvePS" Width="100px" ValidationGroup="GrpAgregar" Visible="false"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RFVConcepto" runat="server" ControlToValidate="DdlConceptoOI" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />Es necesario <b>seleccionar un concepto, </b>por favor ingréselo." InitialValue="-1" ValidationGroup="GrpAgregar"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCEConcepto" runat="server" HighlightCssClass="vco" TargetControlID="RFVConcepto" Width="300px" BehaviorID="VCEConcepto"></ajax:ValidatorCalloutExtender>
@@ -6631,15 +6630,13 @@
TotalCompra = parseFloat($('#<%= TxtTotal.ClientID %>').val().replace(/,/g, '')).toFixed(2);
ImporteAmortizado = $(`.CsSelAmbos${CveCreditoDetalle}`).val().replace(/,/g, '').length == 0 ? 0 : parseFloat($(`.CsSelAmbos${CveCreditoDetalle}`).val().replace(/,/g, ''));
ImporteComision = $(`.CsSelComision${CveCreditoDetalle}`).val().replace(/,/g, '').length == 0 ? 0 : parseFloat($(`.CsSelComision${CveCreditoDetalle}`).val().replace(/,/g, ''));
ImporteComision = isNaN(ImporteComision) ? 0 : ImporteComision;
ImporteDocPorPagar = (ImporteIE - ImporteAmortizado - ImporteComision).toFixed(2);
$(`.CsSelAmbos${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
$(`.CsSelComision${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
$(`.CsCreGlobal`).each(function () {
let stringTemp = $(this).val().replace(/,/g, '');
@@ -6660,15 +6657,18 @@
});
if (((TotalAmortizaciones + TotalComisiones) > TotalCompra) || ((ImporteAmortizado + ImporteComision) > ImporteIE)) {
if ((TotalAmortizaciones > TotalCompra) || ((ImporteAmortizado + ImporteComision) > ImporteIE)) {
TotalAmortizaciones = 0;
TotalComisiones = 0;
//TotalComisiones = 0;
if (Tipo == 1) {
if (Tipo == 1) {
$(`.CsSelAmbos${CveCreditoDetalle}`).val(``);
} else if (Tipo == 2) {
$(`.CsSelComision${CveCreditoDetalle}`).val(``);
if (!isNaN(ImporteComision) && ImporteComision != 0) {
$(`.CsSelComision${CveCreditoDetalle}`).val(``);
}
}
@@ -6679,11 +6679,8 @@
$(`.CsSelAmbos${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
$(`.CsSelComision${CveCreditoDetalle}`).each(function () {
FormatoMoneda3($(this));
});
});
$(`.CsCreGlobal`).each(function () {

View File

@@ -853,6 +853,18 @@ Partial Class Compras_Compras
ViewState("TipoCambio") = value
End Set
End Property
Private Property TipoCambioOriginal As Decimal
Get
Return ViewState("TipoCambioOriginal").ToString.ToDecimal
End Get
Set(value As Decimal)
ViewState("TipoCambioOriginal") = value
End Set
End Property
'Private Property TipoCambio As Double = 0
Private Property OtrosImpuestos As Decimal = 0
Private Property OtrosImpuestosRetenciones As Decimal = 0
@@ -2378,7 +2390,7 @@ Partial Class Compras_Compras
If TrasladoIEPS > 0 Or OtrosImpuestos > 0 Then
If OtrosImpuestos > 0 Then
If OtrosImpuestos > 0 Or TrasladoIEPS > 0 Then
If UsuarioActual.Empresa.Funcionalidad(713).ToEntero = 1 Then
'Si tiene funcionalidad y es Acreedor se muestra modal
@@ -2391,8 +2403,8 @@ Partial Class Compras_Compras
End If
Else
RegistraScript("$('#ModalIEPS').modal('show');")
'Else
' RegistraScript("$('#ModalIEPS').modal('show');")
'BtnCancelarotrosImpuestos.Visible = True
End If
@@ -2656,7 +2668,8 @@ Partial Class Compras_Compras
HfTotalCompra.Value = TxtTotal.Text
TipoCambio = dr("TipoCambio").ToString.ToDecimal
Dim TipoCambioOriginal = dr("TipoCambioOriginal").ToString.ToDouble
TipoCambioOriginal = dr("TipoCambioOriginal").ToString.ToDecimal
If TipoCambio > 1 Then LblTC.Text = String.Format("TC: {0}", TipoCambio.ToString("N4"))
If TipoCambio <> TipoCambioOriginal Then LblTCO.Text = String.Format("<br/>TC Original: {0}", TipoCambioOriginal.ToString("N4"))
@@ -6072,6 +6085,7 @@ Partial Class Compras_Compras
Dim OtrosGastosIngresosCredito As Decimal = gvRowCredito.FCTextBox("TxtComision").Text.ToDecimal
Dim CveIECredito As Integer = gvRowCredito.DataKey("CveIE").ToEntero
Dim CveCreditoDetalleTemp As Integer = gvRowCredito.DataKey("CveCreditoDetalle").ToEntero
Dim CveCreditoTemp As Integer = gvRowCredito.DataKey("CveCredito").ToEntero
If ImportePagoCredito > 0 Then
Dim Pago As New CompraPago
@@ -6093,14 +6107,14 @@ Partial Class Compras_Compras
Exit For
End If
Dim ImporteDifCredito As Decimal = ImporteIEAnticipo - ImportePagoCredito ' CompraActual.Total
Dim ImporteDifCredito As Decimal = (ImporteIEAnticipo + OtrosGastosIngresosCredito) - ImportePagoCredito ' CompraActual.Total
If ImporteDifCredito > 0 Then
' Dim ImportePagoCreditoMN As Decimal = ImportePagoCredito * tipoCambioActual
Dim ImporteDifCreditoMN As Decimal = ImporteDifCredito * tipoCambioActual
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteDifCredito, ImporteDifCreditoMN, 59, Referencia, Concepto, IdCtaContable, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIECredito, CveCreditoDetalle:=CveCreditoDetalleTemp, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteME:=If(tipoCambioActual = 1, 0, ImporteDifCredito), CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteDifCredito, ImporteDifCreditoMN, 50, Referencia, Concepto, IdCtaContable, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIECredito, CveCredito:=CveCreditoTemp, CveCreditoDetalle:=CveCreditoDetalleTemp, CveClasificacion:=CveClasificacionDT, CveSubProyecto:=CveSubProyectoDT, ImporteME:=If(tipoCambioActual = 1, 0, ImporteDifCredito), CveTipoGasto:=CveTipoGastoDT, TipoCambio:=tipoCambioActual, Contabilizable:=SeContabiliza) Then
ErrorPrepoliza = True
End If
@@ -9217,10 +9231,17 @@ Partial Class Compras_Compras
Dim FechaMovimiento As Date = TxtFecha.Text.ToDate
If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then
tipoCambioActual = GlobalTipoCambio(FechaMovimiento).ToString.ToDecimal
tipoCambioActual = If(DivTC.Visible Or TipoCambio > 0, TipoCambio, tipoCambioActual)
tipoCambioPago = GlobalTipoCambio(TxtFechaPago.Text.ToDate).ToString.ToDecimal
If TipoCambioOriginal > 0 Then
tipoCambioActual = TipoCambioOriginal
End If
Else
tipoCambioActual = 1
tipoCambioPago = 1
@@ -9487,7 +9508,7 @@ Partial Class Compras_Compras
'AGREGA MOVIMIENTO
If importeMovimiento <> 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then
Concepto = $"{NombreProveedor} {TxtSerie.Text} - {TxtFolio.Text}"
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIE, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero) Then
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 6, Concepto, FechaMovimiento, IdCtaContable, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedorConcepto, CveIE:=CveIE, CveCreditoDetalle:=CveCreditoDetalle, CveClasificacion:=Row2("CveClasificacion").ToString.ToEntero, CveSubProyecto:=Row2("CveSubProyecto").ToString.ToEntero, ImporteMX:=importeMN, ImporteME:=If(tipoCambioActual = 1, 0, importeMovimiento), TipoCambio:=tipoCambioActual, CveTipoGasto:=Row2("CveTipoGasto").ToString.ToEntero) Then
ErrorPrepoliza = True
End If
End If
@@ -16740,10 +16761,19 @@ Partial Class Compras_Compras
'TxtIVAModal.Text = FormatoNumero(GvRow.DataKey("IVAPorcentaje").ToDouble * 100, 0)
TxtRetIVAModal.Text = FormatoNumero(GvRow.DataKey("RetIVAPorcentaje").ToDouble * 100, 0)
TxtRetISRModal.Text = FormatoNumero(GvRow.DataKey("RetISRPorcentaje").ToDouble * 100, 0)
TxtIEPSModal.Text = FormatoNumero(GvRow.DataKey("IEPSPSPorcentaje").ToDouble * 100, 0)
ViewState("RetIVA") = GvRow.DataKey("RetIVAPorcentaje").ToDouble
ViewState("RetISR") = GvRow.DataKey("RetISRPorcentaje").ToDouble
'TxtRetIVAModal.Text = FormatoNumero(ViewState("RetIVA").ToString().ToDouble * 100, 0)
'TxtRetISRModal.Text = FormatoNumero(ViewState("RetISR").ToString().ToDouble * 100, 0)
TxtPrecio.Text = GvRow.DataKey("PU").FormatoNumero(6)
TxtDescuentoModal.Text = GvRow.DataKey("Descuento").FormatoNumero(6)
TxtOtrosGastos.Text = GvRow.DataKey("OtrosGastos").FormatoNumero
@@ -16919,8 +16949,11 @@ Partial Class Compras_Compras
' DdlIVA.Enabled = False
End If
ViewState("RetIVA") = If(PS("RetIVA").ToString = "-1", ViewState("RetIVA"), PS("RetIVA").ToString).ToString
ViewState("RetISR") = If(PS("RetISR").ToString = "-1", ViewState("RetISR"), PS("RetISR").ToString).ToString
If Not CveFactura > 0 Then
ViewState("RetIVA") = If(PS("RetIVA").ToString = "-1", ViewState("RetIVA"), PS("RetIVA").ToString).ToString
ViewState("RetISR") = If(PS("RetISR").ToString = "-1", ViewState("RetISR"), PS("RetISR").ToString).ToString
End If
If TxtIEPSModal.Text = "" Then
TxtIEPSModal.Text = FormatoNumero(PS("IEPSPorcentaje").ToString.ToDecimal * 100, 0)
End If
@@ -19015,7 +19048,7 @@ Partial Class Compras_Compras
If Not ObjInventario.AddFletesCompras(CveFlete, CveCompra) Then
ErrorTrans = True
End If
'''actualiza la compra para que no se surta en almacen. sino por el flete o importación
''actualiza la compra para que no se surta en almacen. sino por el flete o importación
''If Not ObjCompras.UpdateEstatusAlmacen(CveCompra, 2) Then
'' ErrorTrans = True
''End If