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
Imports DevExpress.Persistent.Base.General
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Linq
Imports System.Linq.Expressions
<DefaultClassOptions()> _
<NavigationItem(False), CreatableItem(False)> _
<DeferredDeletion(False)> _
Public Class GLDetails
    Inherits BaseObject
    Private _GLRows As GLRows
    Private _Side As String
    Private _AmountHUF As Double
    Private _AmountDEV As Double
    Private _ChartOfAccounts As ChartOfAccounts
    Private _AmountHUF_Rolling As Double ' Göngyölt egyenleg !
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Property GLRows As GLRows
        Get
            Return _GLRows
        End Get
        Set(ByVal value As GLRows)
            SetPropertyValue("GLRows", _GLRows, value)
        End Set
    End Property
    Property Side As String
        Get
            Return _Side
        End Get
        Set(ByVal value As String)
            SetPropertyValue("Side", _Side, value)
        End Set
    End Property
    Property AmountHUF As Double
        Get
            Return _AmountHUF
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("AmountHUF", _AmountHUF, value)
        End Set
    End Property
    Property AmountDEV As Double
        Get
            Return _AmountDEV
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("AmountDEV", _AmountDEV, value)
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("IsParent=False")>
    Property ChartOfAccounts As ChartOfAccounts
        Get
            Return _ChartOfAccounts
        End Get
        Set(ByVal value As ChartOfAccounts)
            SetPropertyValue("ChartOfAccounts", _ChartOfAccounts, value)
        End Set
    End Property

    ReadOnly Property ChartsOfAccounts_Contra As ChartOfAccounts
        Get
            If Side = "T" Then
                Return GLRows.CreditChartOfAccounts
            Else
                Return GLRows.DebitChartOfAccounts
            End If
        End Get
    End Property
    ReadOnly Property AmountHUFSign As Double
        Get
            Select Case Side
                Case "T"
                    Return AmountHUF
                Case "K"
                    Return AmountHUF * -1
                Case Else
            End Select
        End Get
    End Property
    ReadOnly Property AmountHUF_Debit As Double
        Get
            If Side = "T" Then
                Return AmountHUF
            Else
                Return 0
            End If
        End Get
    End Property
    ReadOnly Property AmountHUF_Credit As Double
        Get
            If Side = "K" Then
                Return AmountHUF
            Else
                Return 0
            End If
        End Get
    End Property
    ReadOnly Property AmountHUF_Ballance As Double
        Get
            Return AmountHUF_Debit - AmountHUF_Credit
        End Get
    End Property

    <NonPersistent>
    Property AmountHUF_Rolling As Double
        Get
            Return _AmountHUF_Rolling
        End Get
        Set(value As Double)
            SetPropertyValue("AmountHUF_Rolling", _AmountHUF_Rolling, value)
        End Set
    End Property
End Class
