Merge branch 'master' of http://oirigoyen@192.168.10.111:8383/SIG.git
This commit is contained in:
@@ -316,7 +316,26 @@ Partial Class Ventas_ActualizarPrecios
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
DtExcel.TableName = DdlPrecioLista.SelectedItem.Text
|
||||
|
||||
If DdlPrecioLista.SelectedItem IsNot Nothing Then
|
||||
Dim worksheetName As String = DdlPrecioLista.SelectedItem.Text
|
||||
|
||||
Const invalidCharsRegex As String = "[/\\*'?[\]:]+"
|
||||
Const maxLength As Integer = 31
|
||||
Dim safeName As String = Regex.Replace(worksheetName, invalidCharsRegex, " ").Replace(" ", " ").Trim()
|
||||
|
||||
If String.IsNullOrEmpty(safeName) Then
|
||||
safeName = "Precios" ' cannot be empty
|
||||
ElseIf safeName.Length > maxLength Then
|
||||
safeName = safeName.Substring(0, maxLength)
|
||||
End If
|
||||
|
||||
DtExcel.TableName = safeName
|
||||
Else
|
||||
DtExcel.TableName = "Precios"
|
||||
End If
|
||||
|
||||
|
||||
DtExcel.Columns("Codigo").ColumnName = "Código"
|
||||
DtExcel.Columns("PS").ColumnName = "Producto / Servicio"
|
||||
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
||||
|
||||
@@ -203,7 +203,8 @@
|
||||
<br />
|
||||
<asp:UpdatePanel ID="UPDatos" runat="server" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<asp:GridView ID="GvDatos" runat="server" ClientIDMode="Static" AutoGenerateColumns="False" EmptyDataText="No se encontraron Productos o Servicios registrados" ToolTip="Listado de Productos o Servicios" CssClass="table table-striped table-hover Widthall" UseAccessibleHeader="true" GridLines="None">
|
||||
<asp:GridView ID="GvDatos" runat="server" ClientIDMode="Static" AutoGenerateColumns="False" EmptyDataText="No se encontraron Productos o Servicios registrados"
|
||||
ToolTip="Listado de Productos o Servicios" CssClass="table table-striped table-hover Widthall" UseAccessibleHeader="true" GridLines="None">
|
||||
<Columns>
|
||||
<asp:BoundField DataField="Clasificacion" HeaderText="Clasificación" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="10%" SortExpression="OrdenarGV" />
|
||||
<asp:BoundField DataField="TipoPS" HeaderText="Tipo" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="5%" />
|
||||
@@ -373,7 +374,23 @@
|
||||
<script src="/Metronic/assets/global/scripts/datatable.js"></script>
|
||||
<script src="/Metronic/assets/global/plugins/datatables/all.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
|
||||
"date-esMX-pre": function (a) {
|
||||
if (a == null || a == "") {
|
||||
return 0;
|
||||
}
|
||||
var ukDatea = a.split('/');
|
||||
return (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
|
||||
},
|
||||
|
||||
"date-esMX-asc": function (a, b) {
|
||||
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
|
||||
},
|
||||
|
||||
"date-esMX-desc": function (a, b) {
|
||||
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
|
||||
}
|
||||
});
|
||||
var OrdenarGV = function () {
|
||||
var Tam = TamañoVentana();
|
||||
var Alto = Tam.height - 270;
|
||||
@@ -385,7 +402,11 @@
|
||||
scrollCollapse: true,
|
||||
paging: false,
|
||||
searching: false,
|
||||
info: false
|
||||
info: false,
|
||||
|
||||
columnDefs: [
|
||||
{ "type": "date-esMX", targets: 7 }
|
||||
]
|
||||
});
|
||||
$('#GvDatos').parent().parent().children().first().css("position", "static");
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
<asp:GridView ID="GvDatos" CssClass="table table-striped table-hover Widthall" runat="server" AutoGenerateColumns="False" GridLines="None">
|
||||
<Columns>
|
||||
<asp:TemplateField HeaderText="Promoción" ItemStyle-Width="300px" ItemStyle-HorizontalAlign="Left">
|
||||
<asp:TemplateField HeaderText="Promoción" ItemStyle-HorizontalAlign="Left">
|
||||
<ItemTemplate>
|
||||
<asp:HyperLink runat="server" ID="HLPromocion" Text='<%# Eval("Promocion").ToString %>' CssClass="Texto"></asp:HyperLink>
|
||||
</ItemTemplate>
|
||||
|
||||
@@ -5037,6 +5037,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</ContentTemplate>
|
||||
<Triggers>
|
||||
<asp:PostBackTrigger ControlID="BtnDescargar" />
|
||||
</Triggers>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1763,7 +1763,7 @@ Partial Class Clientes
|
||||
DivPortletSucursales.Visible = False
|
||||
DivPortletDireccionEnvio.Visible = False
|
||||
DivPortletAsignaciones.Visible = False
|
||||
DivPortletBitacora.Visible = False
|
||||
'DivPortletBitacora.Visible = False
|
||||
BtnEliminar.Visible = False
|
||||
|
||||
DivProtletRegistrar.Visible = True
|
||||
|
||||
@@ -1867,7 +1867,7 @@ Partial Class PV
|
||||
For Each Row As DataRow In TmpDT.FiltraParametros("EliminarDB = False").Rows
|
||||
Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString.ToEntero()
|
||||
If CveVentaDetalle > 0 Then
|
||||
If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDecimal, Row("PU").ToString.ToDecimal(), Row("ImporteIEPS").ToString.ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("Obs").ToString, UsuarioActual.CveUsuario) Then
|
||||
If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString.ToEntero, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDecimal, Row("PU").ToString.ToDecimal(), Row("ImporteIEPS").ToString.ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("ImporteIVA").ToString.ToDecimal(), Row("PorcentajeIVA").ToString().ToDecimal(), Row("Obs").ToString, UsuarioActual.CveUsuario) Then
|
||||
OcurrioError = True
|
||||
Exit For
|
||||
End If
|
||||
|
||||
@@ -1427,7 +1427,7 @@
|
||||
<td>
|
||||
<asp:TextBox ID="TxtSubTotal2" ClientIDMode="Static" runat="server" BorderStyle="None" Style="text-align: right;" Text="0.00" Width="78px"></asp:TextBox></td>
|
||||
<td>
|
||||
<%-- <asp:LinkButton ID="LkbAgregarComplementos" runat="server" CssClass="btn btn-circle btn-xs gray" Text="<i class='fa fa-bell '></i>"></asp:LinkButton>--%>
|
||||
<%-- <asp:LinkButton ID="LkbAgregarComplementos" runat="server" CssClass="btn btn-circle btn-xs gray" Text="<i class='fa fa-bell '></i>"></asp:LinkButton>--%>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -2723,7 +2723,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</td>
|
||||
<td rowspan="1" colspan="1">
|
||||
<div class="portlet light xspadding bordered whitoutcol" style="width: 450px;">
|
||||
<div class="portlet-title">
|
||||
@@ -3631,6 +3631,19 @@
|
||||
<tr align="left" id="trPaqueteriaDirectaLabel" runat="server" visible="false">
|
||||
<td id="Td4" runat="server">Tipo de Entrega: <b>Entrega Directa</b></td>
|
||||
</tr>
|
||||
<tr align="left" id="trRotacion" runat="server" visible="false">
|
||||
<td id="Td3" runat="server">Próxima Rotación y Balanceo: </td>
|
||||
</tr>
|
||||
<tr align="left" id="trRotacionlbl" runat="server" visible="false">
|
||||
<td><asp:Label runat="server" id="LblRotacion" Text=""></asp:Label></td>
|
||||
</tr>
|
||||
<tr align="left" id="trAlineacion" runat="server" visible="false">
|
||||
<td id="Td7" runat="server">Próxima Alineación: </td>
|
||||
</tr>
|
||||
<tr align="left" id="trAlineacionlbl" runat="server" visible="false">
|
||||
<td><asp:Label runat="server" id="LblAlineacion" Text=""></asp:Label></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</ContentTemplate>
|
||||
@@ -7097,6 +7110,7 @@
|
||||
<asp:TemplateField>
|
||||
<ItemTemplate>
|
||||
<asp:CheckBox ID="ChkAplicar" runat="server" />
|
||||
<asp:HiddenField ID="HdnPorcentajeIVA" ClientIDMode="Static" runat="server" Value='<%# Eval("PorcentajeIVA").ToString %>' />
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:TemplateField HeaderText="Cantidad">
|
||||
@@ -7111,6 +7125,7 @@
|
||||
<asp:BoundField HeaderText="Fecha" DataField="Fecha" DataFormatString="{0:d}" ItemStyle-HorizontalAlign="Center" />
|
||||
<asp:TemplateField HeaderText="Total" ItemStyle-HorizontalAlign="Right">
|
||||
<ItemTemplate>
|
||||
<asp:HiddenField ID="HdnPU" ClientIDMode="Static" runat="server" Value='<%# Eval("PU").ToString %>' />
|
||||
<asp:Literal ID="TtlTotal" runat="server" Text='<%# Eval("Total", "{0:N2}") %>'></asp:Literal>
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
@@ -7427,6 +7442,66 @@
|
||||
TxtImporte.value = "";
|
||||
}
|
||||
}
|
||||
function CalculaSaldoRNCChkDetalle(TxtCantidad, CantidadPendiente, ImporteTotal, Chk) {
|
||||
//ImportesRNCCargo
|
||||
let Importe = 0;
|
||||
if (Chk.checked) {
|
||||
let SaldoMaximoUtilizable = ToDouble(HdnSaldoMaximoUsados.value)
|
||||
let ImportesAsignados = 0;
|
||||
|
||||
$('.ImportesRNCDetalle').each(function () {
|
||||
|
||||
if (Chk.id != $(this).find("td").eq(0).find(":checkbox").attr('id')) {
|
||||
let seleccionado = $(this).find("td").eq(0).find(":checkbox").is(':checked');
|
||||
|
||||
if (seleccionado) {
|
||||
let cantidad = ToDouble($(this).find("td").eq(1).find(":text").val());
|
||||
let porcentajeIVA = ToDouble($(this).find("td").eq(0).find(":hidden").val());
|
||||
let precio = ToDouble($(this).find("td").eq(5).find(":hidden").val());
|
||||
|
||||
let totalcalculableImpuestos = (cantidad * precio);
|
||||
let iva = ToDouble((totalcalculableImpuestos * porcentajeIVA).toFixed(2));
|
||||
|
||||
ImportesAsignados += totalcalculableImpuestos + iva;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Importe = SaldoMaximoUtilizable - ImportesAsignados;
|
||||
|
||||
if (Importe > 0) {
|
||||
|
||||
} else {
|
||||
if (SaldoMaximoUtilizable > 0) {
|
||||
Importe = 0;
|
||||
Chk.checked = false;
|
||||
} else {
|
||||
Importe = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Importe = 0;
|
||||
}
|
||||
|
||||
Importe = ToDouble(Importe.toFixed(2));
|
||||
|
||||
if (Importe > 0) {
|
||||
let pu = (ImporteTotal / CantidadPendiente);
|
||||
|
||||
if (pu > 0) {
|
||||
TxtCantidad.value = (Importe / pu).toString();
|
||||
}
|
||||
|
||||
|
||||
}else {
|
||||
TxtCantidad.value = "0";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function LimitaSaldoRNCChk(TxtImporte, Saldo) {
|
||||
//var Importe = 0;
|
||||
|
||||
@@ -8716,21 +8791,21 @@
|
||||
|
||||
if (TotalRem == TotalNC) {
|
||||
document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.border = "2px solid #04B431";
|
||||
document.getElementById('<%= TxtNCImporte.ClientID %>').style.border = "2px solid #04B431";
|
||||
document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.color = "";
|
||||
document.getElementById('<%= TxtNCImporte.ClientID %>').style.color = "";
|
||||
document.getElementById('<%= TxtNCImporte.ClientID %>').style.border = "2px solid #04B431";
|
||||
document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.color = "";
|
||||
document.getElementById('<%= TxtNCImporte.ClientID %>').style.color = "";
|
||||
|
||||
} else {
|
||||
document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.border = "2px solid #ff0000";
|
||||
document.getElementById('<%= TxtNCImporte.ClientID %>').style.border = "2px solid #ff0000";
|
||||
document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.color = "#ff0000";
|
||||
document.getElementById('<%= TxtNCImporte.ClientID %>').style.color = "#ff0000";
|
||||
} else {
|
||||
document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.border = "2px solid #ff0000";
|
||||
document.getElementById('<%= TxtNCImporte.ClientID %>').style.border = "2px solid #ff0000";
|
||||
document.getElementById('<%= TxtImportesRemisionesNC.ClientID %>').style.color = "#ff0000";
|
||||
document.getElementById('<%= TxtNCImporte.ClientID %>').style.color = "#ff0000";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function CerrarModalRemNC() {
|
||||
if ('<%= UsuarioActual.Empresa.Funcionalidad(344) %>' == '1') {
|
||||
function CerrarModalRemNC() {
|
||||
if ('<%= UsuarioActual.Empresa.Funcionalidad(344) %>' == '1') {
|
||||
AplicarValidarRNC(true);
|
||||
CompararNC();
|
||||
}
|
||||
|
||||
@@ -2907,8 +2907,30 @@ Partial Class Ventas
|
||||
End If
|
||||
MostrarOpcionesPaqueteria()
|
||||
|
||||
'If ViewState("CveCotizacion").ToString().ToEntero() > 0 Then
|
||||
|
||||
'If Not AjustarTotalCotizacionFacturada(ViewState("CveCotizacion").ToString().ToEntero(), TxtTotal.Text.ToDecimal) Then
|
||||
' BtnEmitirImprimir.Visible = True
|
||||
' Alert("Ocurrió un error al ajustar el importe", TipoMensaje.MsgError)
|
||||
'End If
|
||||
|
||||
'End If
|
||||
|
||||
'UNA VEZ CARGADA LAS CONDICIONES DE PAGO INICIALMENTE, NO VUELVE A SOBREESCRIBIR EL VALOR
|
||||
CveFormaPago33Cliente = -1
|
||||
|
||||
If UsuarioActual.CveEmpresa.Contiene(141, 152, 159, 160, 161, 162, 163) Then
|
||||
trRotacion.Visible = True
|
||||
trRotacionlbl.Visible = True
|
||||
trAlineacion.Visible = True
|
||||
trAlineacionlbl.Visible = True
|
||||
|
||||
Dim FechaRotaAlinea As Date = TxtFecha.Text.ToDate
|
||||
LblRotacion.Text = FechaRotaAlinea.AddMonths(6).ToShortDateString
|
||||
LblAlineacion.Text = FechaRotaAlinea.AddMonths(6).ToShortDateString
|
||||
|
||||
UPObservaciones.Update()
|
||||
End If
|
||||
End Sub
|
||||
Private Sub BloqueaClasificaciones()
|
||||
If UsuarioActual.Empresa.Funcionalidad(558) = "1" AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then
|
||||
@@ -7006,17 +7028,15 @@ Partial Class Ventas
|
||||
End If
|
||||
|
||||
Else
|
||||
Dim DrPS As DataRow = Nothing
|
||||
|
||||
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("")
|
||||
|
||||
If Not ClienteDesglosaIEPS Then
|
||||
Dim DrPS As DataRow = Nothing
|
||||
|
||||
'DrPS = GlobalDTProductosServicios(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero(), Estatus:=-1).FiltroPrimero("")
|
||||
|
||||
DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=TmpDT.Rows(e.RowIndex)("CvePS").ToString().ToEntero()).FiltroPrimero("")
|
||||
|
||||
PU = PU * (1 + DrPS("IEPSPorcentaje").ToString().ToDecimal)
|
||||
|
||||
TmpDT.Rows(e.RowIndex)("PorcentajeIEPS") = 0
|
||||
DrPS = Nothing
|
||||
|
||||
End If
|
||||
|
||||
Dim TotalCalculableImpuestos As Decimal = ((Cantidad * PU) - (ObjDescuento.ImporteDescuento))
|
||||
@@ -7039,7 +7059,11 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If DrPS("IVA").ToString().Contiene("-1", "") Then
|
||||
TmpDT.Rows(e.RowIndex)("PorcentajeIVA") = PorcentajeIVA
|
||||
Else
|
||||
TmpDT.Rows(e.RowIndex)("PorcentajeIVA") = DrPS("IVA")
|
||||
End If
|
||||
|
||||
TmpDT.Rows(e.RowIndex)("CveUM") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida").SelectedValue.ToEntero()
|
||||
TmpDT.Rows(e.RowIndex)("UM") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlUnidadMedida").SelectedItem.Text
|
||||
@@ -7073,6 +7097,8 @@ Partial Class Ventas
|
||||
TmpDT.Rows(e.RowIndex)("CveSubProyecto") = GvPS.Rows(e.RowIndex).FCDropDownList("DdlSubProyecto").SelectedValue
|
||||
End If
|
||||
|
||||
DrPS = Nothing
|
||||
|
||||
GvPS.EditIndex = -1
|
||||
GvPS.DataSource = TmpDT
|
||||
DtInv = TmpDT.Copy.FiltraParametros("CveTipoPS = 2")
|
||||
@@ -9714,7 +9740,7 @@ Partial Class Ventas
|
||||
ObjFactura.SetSubProyectoMatriz(Me)
|
||||
ObjFactura.SetSubProyecto(Me)
|
||||
ObjFactura.ClienteSucursal = New Modelos.SucursalModel()
|
||||
If Not CveEmpresaCRM > 0 Then
|
||||
If CveCliente > 0 Then
|
||||
If Me.ClienteSucursal IsNot Nothing Then
|
||||
ObjFactura.ClienteSucursal.RFC = Me.ClienteSucursal.RFC
|
||||
ObjFactura.ClienteSucursal.Nombre = Me.ClienteSucursal.Nombre
|
||||
@@ -9815,7 +9841,7 @@ Partial Class Ventas
|
||||
|
||||
End If
|
||||
|
||||
If Not CveEmpresaCRM > 0 Then ObjFactura.Timbre = PreParaTimbre(ObjFactura)
|
||||
If CveCliente > 0 Then ObjFactura.Timbre = PreParaTimbre(ObjFactura)
|
||||
|
||||
'SI SE ESTA EDITANDO ACTUALIZA LOS IMPORTES DEL DT
|
||||
If GvImpuestosLocales2.Visible AndAlso GvImpuestosLocales2.Enabled Then
|
||||
@@ -16151,7 +16177,7 @@ Partial Class Ventas
|
||||
'End If
|
||||
|
||||
End Sub
|
||||
Private Sub CargaFormatoSucursal()
|
||||
Private Sub CargaFormatoSucursal(Optional RecalcularIVA As Boolean = True)
|
||||
Dim dr = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveSubProyecto = {0}", If(DdlSubProyectoDatos.SelectedValue = "", "-1", DdlSubProyectoDatos.SelectedValue)))
|
||||
If dr IsNot Nothing Then
|
||||
ViewState("SucCalle") = dr("Calle")
|
||||
@@ -16182,7 +16208,7 @@ Partial Class Ventas
|
||||
If CveVenta <= 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" Then
|
||||
DdlIVA.Visible = True
|
||||
End If
|
||||
If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 AndAlso (Not CveVenta > 0 Or EsCreaApartirDe Or CveDevolucion > 0) Then RecalculaIVA()
|
||||
If RecalcularIVA AndAlso TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count > 0 AndAlso (Not CveVenta > 0 Or EsCreaApartirDe Or CveDevolucion > 0) Then RecalculaIVA()
|
||||
'ViewState("SubProyectoPorcentajeIVA") = dr("IVA")
|
||||
ViewState("TipoFormato") = dr("TipoFormato")
|
||||
'ViewState("Serie") = dr("Serie")
|
||||
@@ -16534,7 +16560,7 @@ Partial Class Ventas
|
||||
If TipoAplicacion = 2 Then
|
||||
Descuento = 0
|
||||
SeAjustoPU = True
|
||||
PUModificado = PUPromocion
|
||||
PUModificado = Math.Round(PUPromocion / (1 + If(IncluyeImpuestos, PorcentajeIVA, 0)), 6)
|
||||
Else
|
||||
Descuento = Descuento + PU - TotalPromocion
|
||||
End If
|
||||
@@ -17050,11 +17076,17 @@ Partial Class Ventas
|
||||
DrPoliza("CveTipoPS") = DrPSAdicional("CveTipoPS")
|
||||
DrPoliza("CveTipoInvPS") = DrPSAdicional("Inv_CveMetodoInventario")
|
||||
DrPoliza("NoIdentificacion") = DrPSAdicional("Codigo")
|
||||
|
||||
If Modalidad = "U" Then
|
||||
DrPoliza("Consec") = Index
|
||||
Else
|
||||
DrPoliza("Consec") = TmpDT.Rows.Count + 1
|
||||
Dim ConsecutivoActual As Integer = TmpDT.MAX("Consec").ToEntero()
|
||||
If ConsecutivoActual < 0 Then
|
||||
ConsecutivoActual = 0
|
||||
End If
|
||||
DrPoliza("Consec") = ConsecutivoActual + 1
|
||||
End If
|
||||
|
||||
Row("Orden") = TmpDT.Rows.Count + 1
|
||||
DrPoliza("Cantidad") = If(Dr("Cantidad").ToString().ToDecimal > 0, Dr("Cantidad").ToString().ToDecimal, Cantidad)
|
||||
PU = 0
|
||||
@@ -17128,6 +17160,249 @@ Partial Class Ventas
|
||||
Return Retorno
|
||||
End Function
|
||||
|
||||
'Private Function AgregarProductoServicioCotizacion(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String,
|
||||
' PU As Decimal, Descuento As Decimal, PorcentajeIVA As Decimal, ImporteIVA As Decimal, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, Optional Serie As String = "", Optional TiempoEntrega As String = "",
|
||||
' Optional EntregaDirecta As Integer = 0, Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0,
|
||||
' Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, Optional CuentaPredial As String = "",
|
||||
' Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False,
|
||||
' Optional ImporteProntoPago As Decimal = 0) As Boolean
|
||||
|
||||
' Dim Retorno As Boolean = False
|
||||
' Try
|
||||
' If Not CvePS > 0 Then
|
||||
' Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgError)
|
||||
' Return False
|
||||
' End If
|
||||
|
||||
' Dim Row As DataRow = Nothing
|
||||
' Dim TotalCalculableImpuestos As Decimal = 0
|
||||
' PU = PU.RoundSQL(6) ' el precio unitario puede llevar hasta 6 decimales permitidos
|
||||
' Descuento = Descuento.RoundSQL(NumeroDecimales)
|
||||
|
||||
' If Not TmpDT.Columns.Contains("RetIVA") Then
|
||||
' TmpDT.Columns.Add("RetIVA", GetType(Decimal))
|
||||
' End If
|
||||
|
||||
' Row = TmpDT.NewRow()
|
||||
' Row("CveProyecto") = CveProyecto
|
||||
' Row("Proyecto") = Proyecto
|
||||
' Row("CveSubProyecto") = CveSubProyecto
|
||||
' Row("SubProyecto") = SubProyecto
|
||||
' Row("Serie") = Serie
|
||||
' Row("TiempoEntrega") = TiempoEntrega
|
||||
' If Modalidad = "U" Then
|
||||
' Row("Orden") = Index
|
||||
' Else
|
||||
' Dim ConsecutivoActual As Integer = TmpDT.MAX("Consec").ToEntero()
|
||||
' If ConsecutivoActual < 0 Then
|
||||
' ConsecutivoActual = 0
|
||||
' End If
|
||||
' Row("Orden") = ConsecutivoActual + 1
|
||||
' End If
|
||||
|
||||
' Row("Cantidad") = Cantidad
|
||||
' Row("CveUM") = CveUM
|
||||
' Row("UM") = UM
|
||||
' Row("CveClasificacion") = CveClasificacion
|
||||
' Row("Clasificacion") = Clasificacion
|
||||
' Row("CvePS") = CvePS
|
||||
' Row("Obs") = Obs
|
||||
|
||||
|
||||
' Dim DrPS As DataRow = Nothing
|
||||
|
||||
' DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1
|
||||
|
||||
' If DrPS Is Nothing Then
|
||||
' Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
||||
' Return False
|
||||
' End If
|
||||
|
||||
' If (DrPS("SATClaveUnidadMedida").ToString() = "" Or DrPS("SATClavePS").ToString() = "") Then
|
||||
' 'VALIDA CLAVESAT
|
||||
' If Not DdlTipoComprobante.SelectedValue.Contiene("Ped", "PeC") Then 'DOCUMENTOS DONDE NO SE VALIDA
|
||||
' If DrPS("SATClavePS").ToString() = "" Then
|
||||
' MensajeCveSAT.AppendFormat("<b>{0}-{1}</b>: Sin producto SAT<br/>", DrPS("Codigo").ToString(), DrPS("PS").ToString())
|
||||
' Return False
|
||||
' ElseIf DrPS("SATClaveUnidadMedida").ToString() = "" Then
|
||||
' MensajeCveSAT.AppendFormat("<b>{0}-{1}</b>: Sin Unidad Medida SAT<br/>", DrPS("Codigo").ToString(), DrPS("PS").ToString())
|
||||
' Return False
|
||||
' End If
|
||||
|
||||
' 'If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) AndAlso DrPS("SATClavePS").ToString() = "01010101" Then
|
||||
' ' MensajeCveSAT.AppendFormat("<b>{0}-{1}</b>: El producto/servicio no existe en el catálogo del SAT<br/>", DrPS("Codigo").ToString(), DrPS("PS").ToString())
|
||||
' ' Return False
|
||||
' 'End If
|
||||
' End If
|
||||
' Else
|
||||
' If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) AndAlso DrPS("SATClavePS").ToString() = "01010101" Then
|
||||
' MensajeCveSAT.AppendFormat("<b>{0}-{1}</b>: El producto/servicio no existe en el catálogo del SAT<br/>", DrPS("Codigo").ToString(), DrPS("PS").ToString())
|
||||
' Return False
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' 'verifica si tiene ventaminima
|
||||
' If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString().ToDecimal > 0 Then
|
||||
' 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15...
|
||||
' If Cantidad Mod DrPS("VentaMinima").ToString().ToDecimal <> 0 Then
|
||||
' Alert(String.Format("El producto se vende solo en cantidades de {0}", DrPS("VentaMinima").ToString()))
|
||||
' Return False
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' 'VERIFICA SI EN LA FACTURA PADRE SE DESGLOSO EL IEPS
|
||||
' Dim FacturaDesglosoIEPS As Boolean = ((CveDevolucion > 0 AndAlso NuevaFactura = 1) AndAlso (Me.ObjFacturaNC IsNot Nothing AndAlso Not Me.ObjFacturaNC.VentaDesglosaIEPS))
|
||||
|
||||
' If Not ClienteDesglosaIEPS Then
|
||||
' If Not RegeneraIEPS AndAlso Not FacturaDesglosoIEPS Then
|
||||
' PU = PU * (1 + DrPS("IEPSPorcentaje").ToString().ToDecimal)
|
||||
' VentaDesglosaIEPS = True
|
||||
' End If
|
||||
' DrPS("IEPSPorcentaje") = 0
|
||||
' End If
|
||||
' 'SI YA SE DESGLOSO EL IEPS SE GUARDA LA BANDERA EN ESTA FACTURA
|
||||
' If FacturaDesglosoIEPS Then
|
||||
' VentaDesglosaIEPS = True
|
||||
' End If
|
||||
|
||||
|
||||
' TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento
|
||||
|
||||
' Row("PU") = PU
|
||||
' Row("Codigo") = DrPS("Codigo")
|
||||
' Row("NoIdentificacion") = DrPS("Codigo")
|
||||
' Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria")
|
||||
' Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana")
|
||||
' Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion")
|
||||
' Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion")
|
||||
' If Modalidad = "U" Then
|
||||
' Row("Consec") = Index
|
||||
' Else
|
||||
' Dim ConsecutivoActual As Integer = TmpDT.MAX("Consec").ToEntero()
|
||||
' If ConsecutivoActual < 0 Then
|
||||
' ConsecutivoActual = 0
|
||||
' End If
|
||||
' Row("Consec") = ConsecutivoActual + 1
|
||||
' End If
|
||||
|
||||
' Row("PS") = DrPS("PS")
|
||||
' Row("CodigoPS") = DrPS("PSCodigo").ToString()
|
||||
' Row("CveTipoPS") = DrPS("CveTipoPS")
|
||||
' Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario")
|
||||
' Row("CveTamaño") = DrPS("CveTamaño")
|
||||
|
||||
' If CveClasificacion <= 0 Then Row("CveClasificacion") = DrPS("CveClasificacion")
|
||||
' If Clasificacion = "" Then Row("Clasificacion") = DrPS("Clasificacion")
|
||||
|
||||
' Row("PorcentajeIVA") = PorcentajeIVA
|
||||
|
||||
' Dim ClienteRetIVA = Me.ClienteRetIVA
|
||||
|
||||
' If ClienteRetIVA <= 0 Then
|
||||
' If CBool(DrPS("EsOutSourcing").ToString()) Then
|
||||
' ClienteRetIVA = 0.06D
|
||||
' DdlTipoRetencion.SelectedValueExist("4")
|
||||
' ElseIf DdlTipoRetencion.SelectedValue.Contiene("1", "2") Then
|
||||
' ClienteRetIVA = 0.106667D
|
||||
' ElseIf DdlTipoRetencion.SelectedValue.Contiene("3") Then
|
||||
' ClienteRetIVA = 0.04D
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' LblRetIVA.Text = (ClienteRetIVA * 100).FormatoNumero
|
||||
' TrRetIVA.Style.Add("display", "")
|
||||
' DdlTipoRetencion.Visible = True
|
||||
|
||||
|
||||
' Row("IVA") = PorcentajeIVA
|
||||
' Row("ImporteIVA") = (ImporteIVA).RoundSQL(NumeroDecimales)
|
||||
' Row("ImporteRetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
|
||||
|
||||
|
||||
|
||||
' Row("RetIVA") = (ClienteRetIVA * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
|
||||
|
||||
' Row("ImporteRetISR") = (ClienteRetISR * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
|
||||
' Row("PorcentajeRetIVA") = ClienteRetIVA
|
||||
' Row("PorcentajeRetISR") = ClienteRetISR
|
||||
' Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje")
|
||||
' Row("ImporteIEPS") = (DrPS("IEPSPorcentaje").ToString().ToDecimal * TotalCalculableImpuestos).RoundSQL(NumeroDecimales)
|
||||
' Row("IEPS") = Row("ImporteIEPS")
|
||||
' Row("Descuento") = (Descuento).RoundSQL(NumeroDecimales)
|
||||
' Row("TipoDescuento") = HdnTipoDescuento.Value
|
||||
' Row("CvePromocionDetalle") = CvePromocionDetalle
|
||||
' Row("Total") = (Cantidad * PU)
|
||||
' Row("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales)
|
||||
|
||||
' 'Row("AsientoContableVentas") = DrPS("AsientoContableVentas")
|
||||
' ' Row("IdCtaContVentas") = IdCtaContable
|
||||
' ' Row("AplicaParaConcepto") = AplicaParaConcepto
|
||||
|
||||
' Row("SATClaveProdServ") = DrPS("SATClavePS")
|
||||
' Row("SATClaveUM") = DrPS("SATClaveUnidadMedida")
|
||||
|
||||
' If UsuarioActual.Empresa.UsaAC Then
|
||||
' Row("CvePresupuestoIngreso") = Me.DdlFuenteRecaudacion.SelectedValue
|
||||
' End If
|
||||
|
||||
' Row("EntregaDirecta") = EntregaDirecta
|
||||
' 'Contratos
|
||||
' Row("CveContratoDetalle") = CveContratoDetalle
|
||||
' Row("CveVentaDetalle") = CveVentaDetalle
|
||||
' Row("CveMovimientoDetallePedido") = CveMovimientoDetallePedido
|
||||
' Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
|
||||
' Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
|
||||
' Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
|
||||
' Row("CveVentaDetallePedido2") = CveVentaDetallePedido2
|
||||
' Row("CuentaPredial") = CuentaPredial
|
||||
' Row("EsOutSourcing") = DrPS("EsOutSourcing")
|
||||
' Row("EsCargo") = EsCargo
|
||||
|
||||
' If ImporteProntoPago > 0 Then
|
||||
' Row("ImporteProntoPago") = ImporteProntoPago
|
||||
' Row("TieneProntoPago") = "Si"
|
||||
' 'SOLO DEBE MOSTRASE SI EL PAGO ES DE CONTADO
|
||||
' If RBLPago.SelectedValue = "2" Then
|
||||
' GvPS.Columns(22).Visible = True
|
||||
' thProntoPago.Visible = True
|
||||
' thProntoPago2.Visible = True
|
||||
' End If
|
||||
|
||||
' End If
|
||||
|
||||
' If UsuarioActual.CveEmpresa = 119 Then
|
||||
' If Not RemisionesLista.Count > 0 Then 'SI VIENE DE REMISION NO SE CONSIDERA
|
||||
|
||||
' 'MONEDA DIFERENTE DEL PS AL PRIMER PS AGREGADO
|
||||
' If DdlMoneda.Enabled = False And CveVenta < 0 And TmpDT.Rows.Count > 0 Then
|
||||
' If DdlMoneda.SelectedValue <> DrPS("CveMoneda").ToString() Then
|
||||
' Alert($"La moneda base del producto: <b>{DrPS("PSCodigo").ToString()}</b> es diferente a la moneda del documento.", TipoMensaje.MsgAdvertencia)
|
||||
' Return False
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' 'ACTIVA PRODUCTOS DE LA MISMA MONEDA
|
||||
' If TmpDT.Rows.Count = 0 And CveVenta < 0 Then
|
||||
' DdlMoneda.SelectedValueExist(DrPS("CveMoneda").ToString())
|
||||
' CambiaMoneda()
|
||||
' DdlMoneda.Enabled = False
|
||||
' End If
|
||||
' End If
|
||||
' End If
|
||||
|
||||
' 'RECARGAR GV
|
||||
' TmpDT.Rows.Add(Row)
|
||||
|
||||
' Retorno = True
|
||||
' Catch ex As Exception
|
||||
' Retorno = False
|
||||
' OnError("Ocurrió un error al agregar el producto/servicio", ex)
|
||||
' End Try
|
||||
|
||||
|
||||
' Return Retorno
|
||||
'End Function
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "D A T A - T A B L E S"
|
||||
@@ -17718,6 +17993,9 @@ Partial Class Ventas
|
||||
|
||||
If TbDescuentosRNC.Visible AndAlso ListaNCDesc IsNot Nothing Then
|
||||
TotalRemNCAplicado = ListaNCDesc.Sum(Function(RNC) RNC.TotalRemNCAplicado)
|
||||
If ListaNCBonificacion IsNot Nothing AndAlso ListaNCBonificacion.Count > 0 Then
|
||||
TotalRemNCAplicado += ListaNCBonificacion.Sum(Function(RNC) RNC.TotalRemNCAplicado)
|
||||
End If
|
||||
End If
|
||||
|
||||
Total = (TotalSubTotal - TotalDescuentos - TotalAmortizacion + TotalIVA + TotalIEPS - TotalRetIVA - TotalRetISR - TotalImpuestosLocales)
|
||||
@@ -19692,7 +19970,7 @@ Partial Class Ventas
|
||||
For Each Row As DataRow In TmpDT.Rows
|
||||
Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString().ToEntero()
|
||||
If CveVentaDetalle > 0 Then
|
||||
If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario) Then
|
||||
If Not ObjVentas.UpdateVentaDetalleRemision(Row("CveVentaDetalle").ToString().ToEntero(), Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDecimal, Row("PU").ToString().ToDecimal(), Row("ImporteIEPS").ToString().ToDecimal(), Row("PorcentajeIEPS").ToString().ToDecimal(), Row("ImporteIVA").ToString().ToDecimal(), Row("PorcentajeIVA").ToString().ToDecimal(), Row("Obs").ToString(), UsuarioActual.CveUsuario) Then
|
||||
OcurrioError = True
|
||||
Exit For
|
||||
End If
|
||||
@@ -19753,6 +20031,12 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not OcurrioError Then
|
||||
If RegeneracionPolizas(ObjVentas, ObjAC, ObjConta, ObjBancos) Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
If ObjConta.ValidacionPrePolizaCuadre(-1, 2, CveVenta) Then
|
||||
If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
If ObjConta.ValorPolizaDescuadre = 2 Then
|
||||
@@ -19762,12 +20046,6 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not OcurrioError Then
|
||||
If RegeneracionPolizas(ObjVentas, ObjAC, ObjConta, ObjBancos) Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
OcurrioError = True
|
||||
OnError("Ocurrió un error al actualizar la remisión", ex)
|
||||
@@ -25054,6 +25332,23 @@ Partial Class Ventas
|
||||
e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble});")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub GvDescNCCargosDetalle_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNCCargosDetalle.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
If e.Row.DBCampo("CveVentaDetalleRNC").ToEntero() = 0 Then
|
||||
e.Row.CssClass = "Totales"
|
||||
e.Row.FCCheckBox("ChkAplicar").Visible = False
|
||||
e.Row.FCTextBox("TxtCantidadRNC").Visible = False
|
||||
Else
|
||||
e.Row.CssClass = "ImportesRNCDetalle"
|
||||
e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCChkDetalle({e.Row.FCTextBox("TxtCantidadRNC").ClientID},{e.Row.DBCampo("CantidadPendiente").ToDouble},{e.Row.DBCampo("Total").ToDouble}, this);")
|
||||
'e.Row.FCTextBox("TxtImporte").Attributes.Add("onkeyup", $"LimitaSaldoRNCChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble});")
|
||||
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub GvDescNCBonificaciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNCBonificaciones.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
e.Row.FCCheckBox("ChkAplicar").Attributes.Add("onclick", $"CalculaSaldoRNCBonChk({e.Row.FCTextBox("TxtImporte").ClientID},{e.Row.DBCampo("Saldo").ToDouble}, this);")
|
||||
@@ -25083,15 +25378,6 @@ Partial Class Ventas
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub GvDescNCCargosDetalle_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDescNCCargosDetalle.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.DBCampo("CveVentaDetalleRNC").ToEntero() = 0 Then
|
||||
e.Row.CssClass = "Totales"
|
||||
e.Row.FCCheckBox("ChkAplicar").Visible = False
|
||||
e.Row.FCTextBox("TxtCantidadRNC").Visible = False
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub GvRemisionesNCBon_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvRemisionesNCBon.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
@@ -27034,65 +27320,145 @@ Partial Class Ventas
|
||||
Dim OcurrioError = False
|
||||
Dim MensajeError = ""
|
||||
|
||||
Try
|
||||
'CONVERTIR REMISION - TIPO MONEDA -DOLARES A PESOS
|
||||
If DdlMoneda.SelectedValue.ToEntero() <> 2 AndAlso ChkConvertirDolares.Checked Then
|
||||
|
||||
'ACTUALIZA VENTA
|
||||
If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), LblDescuentos.Text.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), TxtIVA.Text.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), TxtIEPS.Text.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), TxtTotal.Text.ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)),
|
||||
For Each Row As DataRow In TmpDT.Rows
|
||||
Row("PU") = Math.Round(Row("PU").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, 6)
|
||||
Row("Total") = Math.Round(Row("Cantidad").ToString().ToDecimal * Row("PU").ToString().ToDecimal, NumeroDecimales)
|
||||
Row("TotalImporte") = Math.Round(Row("Cantidad").ToString().ToDecimal * Row("PU").ToString().ToDecimal, NumeroDecimales)
|
||||
Row("Descuento") = Math.Round(Row("Descuento").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
|
||||
Row("ImporteIEPS") = Math.Round(Row("ImporteIEPS").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
|
||||
Row("ImporteIVA") = Math.Round(Row("ImporteIVA").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
|
||||
Row("ImporteRetIVA") = Math.Round(Row("ImporteRetIVA").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
|
||||
Row("ImporteRetISR") = Math.Round(Row("ImporteRetISR").ToString().ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
|
||||
Next
|
||||
|
||||
Dim ImpuestosLocales As Double = 0
|
||||
For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
|
||||
If gvr.RowType = DataControlRowType.DataRow Then
|
||||
gvr.FCTextBox("TxtImpuestoLocalPS").Text = (gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble / TxtTipoCambioDlls.Text.Trim.ToDecimal).FormatoNumero
|
||||
ImpuestosLocales += Math.Round(gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales)
|
||||
End If
|
||||
Next
|
||||
|
||||
TxtSubTotal.Text = TmpDT.SUM("Total").ToDecimal.FormatoNumero
|
||||
LblDescuentos.Text = TmpDT.SUM("Descuento").ToDecimal.FormatoNumero
|
||||
LblAmortizacion.Text = Math.Round(LblAmortizacion.Text.Trim.ToDecimal / TxtTipoCambioDlls.Text.Trim.ToDecimal, NumeroDecimales).FormatoNumero
|
||||
TxtIVA.Text = TmpDT.SUM("ImporteIVA").ToDecimal.FormatoNumero
|
||||
TxtRetIVA.Text = TmpDT.SUM("ImporteRetIVA").ToDecimal.FormatoNumero
|
||||
TxtRetISR.Text = TmpDT.SUM("ImporteRetISR").ToDecimal.FormatoNumero
|
||||
TxtIEPS.Text = TmpDT.SUM("ImporteIEPS").ToDecimal.FormatoNumero
|
||||
TxtTotal.Text = (TxtSubTotal.Text.ToDecimal - LblDescuentos.Text.ToDecimal - LblAmortizacion.Text.ToDecimal + TxtIVA.Text.ToDecimal + TxtIEPS.Text.ToDecimal - TxtRetIVA.Text.ToDecimal - TxtRetISR.Text.ToDecimal - ImpuestosLocales).ToDecimal.FormatoNumero
|
||||
|
||||
TipoCambio = TxtTipoCambioDlls.Text.Trim.ToDecimal
|
||||
Moneda = 2
|
||||
End If
|
||||
|
||||
|
||||
'CONVERTIR REMISION - TIPO MONEDA -PESO A DOLARES
|
||||
If DdlMoneda.SelectedValue.ToEntero() <> 1 AndAlso ChkConvertirDoctoPesos.Checked Then
|
||||
Dim Importe As Decimal
|
||||
Dim TCC As Decimal = TxtTipoCambio.Text.Trim.ToDecimal
|
||||
For Each Row As DataRow In TmpDT.Rows
|
||||
Row("PU") = Math.Round(Row("PU").ToString().ToDecimal * TCC, 6)
|
||||
Row("Total") = Math.Round(Row("Cantidad").ToString().ToDecimal * Row("PU").ToString().ToDecimal, NumeroDecimales)
|
||||
Row("TotalImporte") = Math.Round(Row("Cantidad").ToString().ToDecimal * Row("PU").ToString().ToDecimal, NumeroDecimales)
|
||||
Row("Descuento") = Math.Round(Row("Descuento").ToString().ToDecimal * TCC, NumeroDecimales)
|
||||
Importe = Row("Total").ToString().ToDecimal - Row("Descuento").ToString().ToDecimal
|
||||
Row("ImporteIEPS") = Math.Round(Importe * Row("PorcentajeIEPS").ToString().ToDecimal, NumeroDecimales)
|
||||
Row("ImporteIVA") = Math.Round(Importe * Row("PorcentajeIVA").ToString().ToDecimal, NumeroDecimales)
|
||||
Row("ImporteRetIVA") = Math.Round(Importe * Row("PorcentajeRetIVA").ToString().ToDecimal, NumeroDecimales)
|
||||
Row("ImporteRetISR") = Math.Round(Importe * Row("PorcentajeRetISR").ToString().ToDecimal, NumeroDecimales)
|
||||
Next
|
||||
|
||||
Dim ImpuestosLocales As Double = 0
|
||||
For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
|
||||
If gvr.RowType = DataControlRowType.DataRow Then
|
||||
gvr.FCTextBox("TxtImpuestoLocalPS").Text = (gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble * TxtTipoCambio.Text.Trim.ToDecimal).FormatoNumero
|
||||
ImpuestosLocales += Math.Round(gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble * TxtTipoCambio.Text.Trim.ToDecimal, NumeroDecimales)
|
||||
End If
|
||||
Next
|
||||
|
||||
TxtSubTotal.Text = TmpDT.SUM("Total").ToDecimal.FormatoNumero
|
||||
LblDescuentos.Text = TmpDT.SUM("Descuento").ToDecimal.FormatoNumero
|
||||
LblAmortizacion.Text = Math.Round(LblAmortizacion.Text.Trim.ToDecimal * TxtTipoCambio.Text.Trim.ToDecimal, NumeroDecimales).FormatoNumero
|
||||
TxtIVA.Text = TmpDT.SUM("ImporteIVA").ToDecimal.FormatoNumero
|
||||
TxtRetIVA.Text = TmpDT.SUM("ImporteRetIVA").ToDecimal.FormatoNumero
|
||||
TxtRetISR.Text = TmpDT.SUM("ImporteRetISR").ToDecimal.FormatoNumero
|
||||
TxtIEPS.Text = TmpDT.SUM("ImporteIEPS").ToDecimal.FormatoNumero
|
||||
TxtTotal.Text = (TxtSubTotal.Text.ToDecimal - LblDescuentos.Text.ToDecimal - LblAmortizacion.Text.ToDecimal + TxtIVA.Text.ToDecimal + TxtIEPS.Text.ToDecimal - TxtRetIVA.Text.ToDecimal - TxtRetISR.Text.ToDecimal - ImpuestosLocales).ToDecimal.FormatoNumero
|
||||
|
||||
|
||||
TipoCambio = 1
|
||||
Moneda = 1
|
||||
End If
|
||||
|
||||
|
||||
'ACTUALIZA VENTA
|
||||
If Not ObjVentas.UpdateVentas(TxtSubTotal.Text.ToDouble(), LblDescuentos.Text.ToDouble(), TxtIVA.Text.ToDouble(), TxtIEPS.Text.ToDouble(), TxtTotal.Text.ToDouble(),
|
||||
Moneda, TipoCambio, TxtFecha.Text.Trim.ToDate, TxtObsFact.Text.Trim,
|
||||
UsuarioActual.CveEmpresa, CveVenta, 0, 0,
|
||||
Vigencia:=TxtFechaVencimientoCotizacion.Text.Trim.ToDate, CondicionesPago:=If(RBLPago.SelectedValue = "2", 0, 1),
|
||||
PedidoContrato:=TxtPedidoContrato.Text, AtencionA:=TxtAtencionA.Text.Trim, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero(), CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero(),
|
||||
CveCliente:=CveCliente, CveClienteSucursal:=CveClienteSucursal, OrdenCompra:=TxtOrdenCompra.Text, RetIVA:=TxtRetIVA.Text.ToDecimal, RetISR:=TxtRetISR.Text.ToDecimal,
|
||||
TipoDocto:=DdlTipoComprobante.SelectedValue, Kilometraje:=TxtKilometraje.Text.ToDouble, CveUsoCFDi:=DdlUsoCFDI.SelectedValue.ToEntero()) Then
|
||||
MensajeError = "Ocurrió un error al actualizar la información de la cotización"
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
'ELIMINA DETALLES
|
||||
If Not ObjVentas.RemoveVentasDetalle(CveVenta) Then
|
||||
MensajeError = "Ocurrió un error al actualizar las partidas de la cotización"
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
'RE-INSERTA DETALLES
|
||||
For Each Row As DataRow In TmpDT.Rows
|
||||
If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDouble, Row("CveUM").ToString().ToEntero(),
|
||||
Row("PU").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("ImporteIVA").ToString().ToDouble, Math.Round((Row("Total").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)) * (1 + Row("PorcentajeIVA").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)))), 6),
|
||||
Row("Obs").ToString(), Row("Descuento").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(),
|
||||
PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDouble(If(ChkConvertirDoctoPesos.Checked, TxtTipoCambio.Text.ToDecimal, 1)), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(),
|
||||
PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal) Then
|
||||
MensajeError = "Ocurrió un error al guardar las partidas de la cotización"
|
||||
MensajeError = "Ocurrió un error al actualizar la información de la cotización"
|
||||
OcurrioError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
|
||||
If gvr.RowType = DataControlRowType.DataRow Then
|
||||
If Not ObjVentas.UpdateVentaImpuestoLocales(CveVenta, gvr.DataKey("CveImpuestoLocal").ToString().ToEntero(), gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble) Then
|
||||
MensajeError = "Ocurrió un error al actualizar los impuestos locales"
|
||||
'ELIMINA DETALLES
|
||||
If Not ObjVentas.RemoveVentasDetalle(CveVenta) Then
|
||||
MensajeError = "Ocurrió un error al actualizar las partidas de la cotización"
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
'RE-INSERTA DETALLES
|
||||
For Each Row As DataRow In TmpDT.Rows
|
||||
If Not ObjVentas.AddVentaDetalle(CveVenta, Row("CvePS").ToString().ToEntero(), Row("Cantidad").ToString().ToDouble, Row("CveUM").ToString().ToEntero(),
|
||||
Row("PU").ToString().ToDouble(), Row("ImporteIVA").ToString().ToDouble, Math.Round((Row("Total").ToString().ToDouble() * (1 + Row("PorcentajeIVA").ToString().ToDouble())), 6),
|
||||
Row("Obs").ToString(), Row("Descuento").ToString().ToDouble(), Row("TipoDescuento").ToString().ToEntero(), Row("CveSubProyecto").ToString().ToEntero(), Row("CvePresupuestoIngreso").ToString().ToEntero(),
|
||||
PorcentajeIVA:=Row("PorcentajeIVA").ToString().ToDecimal, IEPS:=Row("ImporteIEPS").ToString().ToDouble(), PorcentajeIEPS:=Row("PorcentajeIEPS").ToString().ToDouble, TiempoEntrega:=Row("TiempoEntrega").ToString(),
|
||||
PorcentajeRetIVA:=Row("PorcentajeRetIVA").ToString().ToDecimal, ImporteRetIVA:=Row("ImporteRetIVA").ToString().ToDecimal) Then
|
||||
MensajeError = "Ocurrió un error al guardar las partidas de la cotización"
|
||||
OcurrioError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
For Each gvr As GridViewRow In GvImpuestosLocales2.Rows
|
||||
If gvr.RowType = DataControlRowType.DataRow Then
|
||||
If Not ObjVentas.UpdateVentaImpuestoLocales(CveVenta, gvr.DataKey("CveImpuestoLocal").ToString().ToEntero(), gvr.FCTextBox("TxtImpuestoLocalPS").Text.ToDouble) Then
|
||||
MensajeError = "Ocurrió un error al actualizar los impuestos locales"
|
||||
OcurrioError = True
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
'ORDEN PRODUCCION
|
||||
If UsuarioActual.CveEmpresa.Contiene(126) Then
|
||||
If CveVenta > 0 And DdlOrdenProduccion.SelectedValue.ToEntero() > 0 Then
|
||||
If Not ObjCGame.UpdateOrdenProduccionVenta(DdlOrdenProduccion.SelectedValue.ToEntero(), CveVenta) Then
|
||||
MensajeError = "Ocurrió un error al actualizar la orden de producción"
|
||||
OcurrioError = True
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
'ORDEN PRODUCCION
|
||||
If UsuarioActual.CveEmpresa.Contiene(126) Then
|
||||
If CveVenta > 0 And DdlOrdenProduccion.SelectedValue.ToEntero() > 0 Then
|
||||
If Not ObjCGame.UpdateOrdenProduccionVenta(DdlOrdenProduccion.SelectedValue.ToEntero(), CveVenta) Then
|
||||
MensajeError = "Ocurrió un error al actualizar la orden de producción"
|
||||
OcurrioError = True
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
'If ObjConta.ValidacionPrePolizaCuadre(-1, 2, CveVenta) Then
|
||||
' If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
' If ObjConta.ValorPolizaDescuadre = 2 Then
|
||||
' OcurrioError = True
|
||||
' MensajeError = ObjConta.MensajePolizaDescuadre
|
||||
' End If
|
||||
' End If
|
||||
'End If
|
||||
Catch ex As Exception
|
||||
OcurrioError = True
|
||||
OnError("Ocurrió un error al guardar la cotización", ex)
|
||||
End Try
|
||||
|
||||
'If ObjConta.ValidacionPrePolizaCuadre(-1, 2, CveVenta) Then
|
||||
' If ObjConta.ValorPolizaDescuadre > 0 Then
|
||||
' If ObjConta.ValorPolizaDescuadre = 2 Then
|
||||
' OcurrioError = True
|
||||
' MensajeError = ObjConta.MensajePolizaDescuadre
|
||||
' End If
|
||||
' End If
|
||||
'End If
|
||||
|
||||
If OcurrioError Then
|
||||
ObjVentas.RollBack()
|
||||
@@ -27322,6 +27688,61 @@ Partial Class Ventas
|
||||
UpPS.Update()
|
||||
UpParametros.Update()
|
||||
End Sub
|
||||
|
||||
Private Function AjustarTotalCotizacionFacturada(CveCotizacion As Integer, TotalAjustar As Decimal) As Boolean
|
||||
Dim ErrorAjuste As Boolean = False
|
||||
|
||||
Dim ObjCotizacion As New Modelos.Factura(UsuarioActual, CveCotizacion, UsuarioActual.CveEmpresa)
|
||||
|
||||
If ObjCotizacion.CveMoneda = 1 Then
|
||||
Dim TotalNuevoDocumento As Decimal = TotalAjustar
|
||||
|
||||
Dim Diferencia As Decimal = (ObjCotizacion.Total - TotalNuevoDocumento)
|
||||
|
||||
If Diferencia <> 0 Then
|
||||
'AJUSTAR EN EL IVA
|
||||
For Each RowNuevoDocumento As DataRow In TmpDT.Rows
|
||||
Dim CveVentaDetalleCotizacion As Integer = RowNuevoDocumento("CveVentaDetalleCotizacion").ToString().ToEntero()
|
||||
|
||||
Dim ImporteIVANuevoDocumento As Decimal = RowNuevoDocumento("ImporteIVA").ToString().ToDecimal()
|
||||
Dim ImporteIEPSNuevoDocumento As Decimal = RowNuevoDocumento("ImporteIEPS").ToString().ToDecimal()
|
||||
|
||||
If CveVentaDetalleCotizacion > 0 Then
|
||||
'AJUSTAR IVA
|
||||
If ImporteIVANuevoDocumento > 0 Then
|
||||
Dim ImporteIVACotizacion As Decimal = ObjCotizacion.DtDetalle.FiltroPrimeroValor("ImporteIVA", $"CveVentaDetalle={CveVentaDetalleCotizacion}").ToDecimal
|
||||
|
||||
If ImporteIVANuevoDocumento <> ImporteIVACotizacion Then
|
||||
RowNuevoDocumento("ImporteIVA") = ImporteIVACotizacion
|
||||
End If
|
||||
End If
|
||||
|
||||
'AJUSTAR IEPS
|
||||
If ImporteIEPSNuevoDocumento > 0 Then
|
||||
Dim ImporteIEPSCotizacion As Decimal = ObjCotizacion.DtDetalle.FiltroPrimeroValor("ImporteIEPS", $"CveVentaDetalle={CveVentaDetalleCotizacion}").ToDecimal
|
||||
|
||||
If ImporteIEPSNuevoDocumento <> ImporteIEPSCotizacion Then
|
||||
RowNuevoDocumento("ImporteIEPS") = ImporteIEPSCotizacion
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
CalculaTotalesVenta(RecalculaImpuestosLocales:=False)
|
||||
|
||||
If Math.Abs(ObjCotizacion.Total - TotalAjustar) > 0 OrElse Math.Abs(TxtTotal.Text.ToDecimal - TotalAjustar) > 0 Then
|
||||
ErrorAjuste = True
|
||||
End If
|
||||
|
||||
End If
|
||||
ObjCotizacion.Dispose()
|
||||
|
||||
Return Not ErrorAjuste
|
||||
End Function
|
||||
|
||||
Private Class MVentaDetalleCotizacion
|
||||
Public Property CveVentaDetalle As Integer
|
||||
Public Property Cantidad As Decimal
|
||||
@@ -27455,6 +27876,11 @@ Partial Class Ventas
|
||||
tCantidad = If(ChkCotProductos.Checked, GvCotPS.Rows(IndiceGVCotDataKey(GvCotPS, Dr("CveVentaDetalle").ToString())).FCTextBox("TxtCantidadCot").Text.ToDecimal, Dr("Cantidad")).ToString().ToDecimal
|
||||
End If
|
||||
|
||||
'AgregarProductoServicioCotizacion(tCantidad, Dr("CveUM").ToString().ToEntero(), Dr("UM").ToString(), Dr("CveClasificacion").ToString().ToEntero(), Dr("Clasificacion").ToString(),
|
||||
' Dr("CvePS").ToString().ToEntero(), Dr("PS").ToString(), Dr("Obs").ToString(), Dr("PU").ToString().ToDecimal, Dr("Descuento").ToString().ToDecimal,
|
||||
' Dr("PorcentajeIVA").ToString().ToDecimal, Dr("IVA").ToString().ToDecimal,
|
||||
' Dr("CveProyecto").ToString().ToEntero(), Dr("Proyecto").ToString(), Dr("CveSubProyecto").ToString().ToEntero(), Dr("SubProyecto").ToString(),
|
||||
' CveContratoDetalle:=Dr("CveContratoDetalle").ToString().ToEntero(), CveVentaDetalleCotizacion:=Dr("CveVentaDetalle").ToString().ToEntero(), SeActualiza:=True)
|
||||
AgregarProductoServicio(tCantidad, Dr("CveUM").ToString().ToEntero(), Dr("UM").ToString(), Dr("CveClasificacion").ToString().ToEntero(), Dr("Clasificacion").ToString(),
|
||||
Dr("CvePS").ToString().ToEntero(), Dr("PS").ToString(), Dr("Obs").ToString(), Dr("PU").ToString().ToDecimal, Dr("Descuento").ToString().ToDecimal,
|
||||
Dr("CveProyecto").ToString().ToEntero(), Dr("Proyecto").ToString(), Dr("CveSubProyecto").ToString().ToEntero(), Dr("SubProyecto").ToString(),
|
||||
@@ -28722,6 +29148,11 @@ Partial Class Ventas
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
'If Not AjustarTotalCotizacionFacturada(Me.CveVenta) Then
|
||||
' Alert("Ocurrió un error al ajustar el importe", TipoMensaje.MsgError)
|
||||
' Exit Sub
|
||||
'End If
|
||||
|
||||
End If
|
||||
|
||||
'CARGA LO PENDIENTE POR FACTURAR DE REMISION
|
||||
|
||||
Reference in New Issue
Block a user