Module Utilidades

    Function CalcularDiasDelAnio(Fecha As Date) As Integer
        Dim valor As Integer
        Dim Fecha1 As Date
        Dim Fecha2 As Date

        Fecha1 = Convert.ToDateTime("01/01/" + Fecha.Year.ToString)
        Fecha2 = Convert.ToDateTime("31/12/" + Fecha.Year.ToString)

        valor = DateDiff(DateInterval.Day, Fecha1, Fecha2)
        valor = valor + 1

        Return valor
    End Function

    Function Days360(StartDate As DateTime, EndDate As DateTime) As Integer
        Dim Months As Integer = (EndDate.Year - StartDate.Year) * 12 + EndDate.Month - StartDate.Month
        Dim Days As Integer = Math.Min(30, EndDate.Day) - Math.Min(30, StartDate.Day)
        Return Months * 30 + Days
    End Function

    Function DiasDeUnPeriodo(vCodigoPeriodo As String) As Integer
        Dim valor As Integer = 0

        If vCodigoPeriodo = "M" Then
            valor = 30
        End If
        If vCodigoPeriodo = "T" Then
            valor = 90
        End If
        If vCodigoPeriodo = "S" Then
            valor = 180
        End If

        Return valor
    End Function
    Public Function GenerarTransId() As String
        Dim res As String
        Dim serialGuid As Guid = Guid.NewGuid()
        Dim uniqueSerial As String = serialGuid.ToString("N")
        Dim uniqueSerialLength As String = uniqueSerial.Substring(0, 20).ToUpper()


        res = "SINV" & uniqueSerialLength

        Return res
    End Function
End Module
