Imports System
Imports System.ComponentModel

Imports DevExpress.Xpo
Imports DevExpress.Data.Filtering

Imports DevExpress.ExpressApp
Imports DevExpress.Persistent.Base
Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.Persistent.Validation

<DefaultClassOptions()> _
<NavigationItem("Customers")> _
Public Class CustomersGLParameters 'partner főkönyvi kategória
    Inherits BaseObject
    Private _ShortName As String
    Private _ChartOfAccountsIn As ChartOfAccounts '--- Vevői számla
    Private _ChartOfAccountsOut As ChartOfAccounts '--- Szállítói számla
    Private _ChartOfAccountsNo As ChartOfAccounts '--- Elszámolási számla
    Private _DefaultforBusiness As Boolean = False
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    <RuleRequiredField("CustomersGLParameters-ShortName", DefaultContexts.Save)> _
    Property ShortName() As String
        Get
            Return _ShortName
        End Get
        Set(ByVal value As String)
            SetPropertyValue("ShortName", _ShortName, value)
        End Set
    End Property
    '<Browsable(False)>
    'Property ChartOfAccountsIn() As ChartOfAccounts
    '    Get
    '        Return _ChartofAccountsIn
    '    End Get
    '    Set(ByVal value As ChartOfAccounts)
    '        SetPropertyValue("ChartOfAccountsIn", _ChartofAccountsIn, value)
    '    End Set
    'End Property
    '<Browsable(False)>
    'Property ChartOfAccountsOut() As ChartOfAccounts
    '    Get
    '        Return _ChartofAccountsOut
    '    End Get
    '    Set(ByVal value As ChartOfAccounts)
    '        SetPropertyValue("ChartOfAccountsOut", _ChartofAccountsOut, value)
    '    End Set
    'End Property
    '<Browsable(False)>
    'Property ChartOfAccountsNo As ChartOfAccounts
    '    Get
    '        Return _ChartofAccountsNo
    '    End Get
    '    Set(ByVal value As ChartOfAccounts)
    '        SetPropertyValue("ChartOfAccountsNo", _ChartofAccountsNo, value)
    '    End Set
    'End Property
    Property DefaultforBusiness As Boolean
        Get
            Return _DefaultforBusiness
        End Get
        Set(value As Boolean)
            SetPropertyValue("DefaultforBusiness", _DefaultforBusiness, value)
        End Set
    End Property

    <Association("CustomersGLParameters-CustomersGLParametersYear", GetType(CustomersGLParametersYear)), VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property CustomersGLParametersYear As XPCollection(Of CustomersGLParametersYear)
        Get
            Return GetCollection(Of CustomersGLParametersYear)("CustomersGLParametersYear")
        End Get
    End Property
    Public Function GetChartOfAccounts(_AccountYear As Long, _CustomersGLParametersMode As eVATMode) As ChartOfAccounts
        Dim _ChartOfAccounts As ChartOfAccounts = Nothing
        Dim _CustomersGLParametersYear As CustomersGLParametersYear
        Select Case _CustomersGLParametersMode
            Case eVATMode.eIn
                For Each _CustomersGLParametersYear In Me.CustomersGLParametersYear
                    If _CustomersGLParametersYear.AccountYear = _AccountYear Then
                        _ChartOfAccounts = _CustomersGLParametersYear.ChartOfAccountsIn
                        Exit For
                    End If
                Next
            Case eVATMode.eOut
                For Each _CustomersGLParametersYear In Me.CustomersGLParametersYear
                    If _CustomersGLParametersYear.AccountYear = _AccountYear Then
                        _ChartOfAccounts = _CustomersGLParametersYear.ChartOfAccountsOut
                        Exit For
                    End If
                Next
        End Select
        Return _ChartOfAccounts
    End Function

End Class

<DefaultClassOptions(), NavigationItem(False), CreatableItem(False)> _
<RuleCriteria("RuleCriteria CustomersGLParametersYear-ChartOfAccountsOut", DefaultContexts.Save, "ChartOfAccountsOut.Children.Count=0", "Csak gyermek objektum választható ki!", SkipNullOrEmptyValues:=False)> _
<RuleCriteria("RuleCriteria CustomersGLParametersYear-ChartOfAccountsIn", DefaultContexts.Save, "ChartOfAccountsIn.Children.Count=0", "Csak gyermek objektum választható ki!", SkipNullOrEmptyValues:=False)> _
Public Class CustomersGLParametersYear
    Inherits BaseObject

    Private _CustomersGLParameters As CustomersGLParameters
    Private _AccountYear As Long
    Private _ChartOfAccountsOut As ChartOfAccounts
    Private _ChartOfAccountsIn As ChartOfAccounts
    Private _ChartOfAccountsNo As ChartOfAccounts
    Private _ChartOfAccountsAdvanceOut As ChartOfAccounts
    Private _ChartOfAccountsAdvanceIn As ChartOfAccounts
    Public Sub New(ByVal session As Session)
        MyBase.New(session)

    End Sub

    <Association("CustomersGLParameters-CustomersGLParametersYear", GetType(CustomersGLParameters))> _
    Property CustomersGLParameters As CustomersGLParameters
        Get
            Return _CustomersGLParameters
        End Get
        Set(value As CustomersGLParameters)
            SetPropertyValue("CustomersGLParameters", _CustomersGLParameters, value)
        End Set
    End Property
    Property AccountYear As Long
        Get
            Return _AccountYear
        End Get
        Set(value As Long)
            SetPropertyValue("AccountYear", _AccountYear, value)
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("AccountYear='@This.AccountYear'")>
    Property ChartOfAccountsOut As ChartOfAccounts
        Get
            Return _ChartOfAccountsOut
        End Get
        Set(value As ChartOfAccounts)
            SetPropertyValue("ChartOfAccountsOut", _ChartOfAccountsOut, value)
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("AccountYear='@This.AccountYear'")>
    Property ChartOfAccountsIn As ChartOfAccounts
        Get
            Return _ChartOfAccountsIn
        End Get
        Set(value As ChartOfAccounts)
            SetPropertyValue("ChartOfAccountsIn", _ChartOfAccountsIn, value)
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("AccountYear='@This.AccountYear'")>
    Property ChartOfAccountsNo As ChartOfAccounts
        Get
            Return _ChartofAccountsNo
        End Get
        Set(ByVal value As ChartOfAccounts)
            SetPropertyValue("ChartOfAccountsNo", _ChartofAccountsNo, value)
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("AccountYear='@This.AccountYear'")>
    Property ChartOfAccountsAdvanceOut As ChartOfAccounts
        Get
            Return _ChartOfAccountsAdvanceOut
        End Get
        Set(value As ChartOfAccounts)
            SetPropertyValue("ChartOfAccountsAdvanceOut", _ChartOfAccountsAdvanceOut, value)
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("AccountYear='@This.AccountYear'")>
    Property ChartOfAccountsAdvanceIn As ChartOfAccounts
        Get
            Return _ChartOfAccountsAdvanceIn
        End Get
        Set(value As ChartOfAccounts)
            SetPropertyValue("ChartOfAccountsAdvanceIn", _ChartOfAccountsAdvanceIn, value)
        End Set
    End Property

End Class



