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
Imports DevExpress.ExpressApp.ConditionalAppearance

<DefaultClassOptions()> _
<NavigationItem(False), CreatableItem(False)> _
<DeferredDeletion(False)> _
<Appearance("Disable UserCreated,ObjectCreated-TrialBalance", AppearanceItemType:="ViewItem", Enabled:=False, TargetItems:="ObjectCreated,UserCreated", Criteria:="1=1")> _
Public Class TrialBalance
    Inherits BaseObject
    Private _TrialBalanceHeader As TrialBalanceHeader
    Private _RowIndex As Long 'Sor index 
    Private _AccountNumber As String
    Private _ShortName As String
    Private _IsParent As Boolean = True
    Private _CustomersFrom As CustomersFrom
    Private _DebitAmountHUF As Double
    Private _CreditAmountHUF As Double
    Private _DebitRAmountHUF As Double
    Private _CreditRAmountHUF As Double
    Private _ChartOfAccounts As ChartOfAccounts
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    <Association("TrialBalanceHeader-TrialBalance", GetType(TrialBalanceHeader))> _
    Property TrialBalanceHeader() As TrialBalanceHeader
        Get
            Return _TrialBalanceHeader
        End Get
        Set(ByVal value As TrialBalanceHeader)
            SetPropertyValue("TrialBalanceHeader", _TrialBalanceHeader, value)
        End Set
    End Property
    Property RowIndex As Long
        Get
            Return _RowIndex
        End Get
        Set(value As Long)
            SetPropertyValue("RowIndex", _RowIndex, value)
        End Set
    End Property
    Property AccountNumber() As String
        Get
            Return _AccountNumber
        End Get
        Set(ByVal value As String)
            SetPropertyValue("AccountNumber", _AccountNumber, value)
        End Set
    End Property
    <Size(255)> _
    Property ShortName() As String
        Get
            Return _ShortName
        End Get
        Set(ByVal value As String)
            SetPropertyValue("ShortName", _ShortName, value)
        End Set
    End Property
    Property IsParent() As Boolean
        Get
            Return _IsParent
        End Get
        Set(ByVal value As Boolean)
            SetPropertyValue("IsParent", _IsParent, value)
        End Set
    End Property
    Property CustomersForm() As CustomersFrom
        Get
            Return _CustomersFrom
        End Get
        Set(ByVal value As CustomersFrom)
            SetPropertyValue("CustomersForm", _CustomersFrom, value)
        End Set
    End Property

    Property DebitAmountHUF() As Double
        Get
            Return Math.Round(_DebitAmountHUF, 2, MidpointRounding.AwayFromZero)
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("DebitAmountHUF", _DebitAmountHUF, Math.Round(value, 2, MidpointRounding.AwayFromZero))
        End Set
    End Property
    Property CreditAmountHUF() As Double
        Get
            Return Math.Round(_CreditAmountHUF, 2, MidpointRounding.AwayFromZero)
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("CreditAmountHUF", _CreditAmountHUF, Math.Round(value, 2, MidpointRounding.AwayFromZero))
        End Set
    End Property

    Property DebitRAmountHUF() As Double
        Get
            Return Math.Round(_DebitRAmountHUF, 2, MidpointRounding.AwayFromZero)
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("DebitRAmountHUF", _DebitRAmountHUF, Math.Round(value, 2, MidpointRounding.AwayFromZero))
        End Set
    End Property
    Property CreditRAmountHUF() As Double
        Get
            Return Math.Round(_CreditRAmountHUF, 2, MidpointRounding.AwayFromZero)
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("CreditRAmountHUF", _CreditRAmountHUF, Math.Round(value, 2, MidpointRounding.AwayFromZero))
        End Set
    End Property
    <Browsable(False)> _
    Property ChartOfAccounts As ChartOfAccounts
        Get
            Return _ChartOfAccounts
        End Get
        Set(value As ChartOfAccounts)
            SetPropertyValue("ChartOfAccounts", _ChartOfAccounts, value)
        End Set
    End Property

    ReadOnly Property ShortNameFormatted As String
        Get
            Dim s As String
            s = ""
            For i = 1 To Len(AccountNumber)
                s += "   "
            Next
            Return s & ShortName
        End Get
    End Property
    ReadOnly Property LevelNumber As Long
        Get
            Return Len(AccountNumber)
        End Get
    End Property



End Class
