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 System.Linq

<DefaultClassOptions()> _
<NavigationItem(False), CreatableItem(False)> _
<DeferredDeletion(False)> _
Public Class PCIDetail
    Inherits BaseObject
    Private _PCIGroup As PCIGroup
    Private _MainType As String
    Private _CustomersFrom As CustomersFrom
    Private _Customers As Customers
    Private _PartnerType As ePartnerType
    Private _ConnectInfo As String
    Private _DocumentNumber As String = ""
    Private _RegistryNumber As String = ""
    Private _CurrencyName As CurrencyName
    Private _BallanceHUF As Double
    Private _BallanceDEV As Double
    Private _DateExecution As Date
    Private _DateCreated As Date
    Private _CurrencyRate As Double

    Private _DatePayment_Account As Date
    Private _DateExecution_Account As Date
    Private _CurrencyName_Account As CurrencyName
    Private _AmountHUF_Account As Double
    Private _AmountDEV_Account As Double
    Private _Paymode_Account As ePayMode

    Private _ShortName As String
    Private _Description As String

    Private _BallanceState As Long
    Private _BallanceRateDiff As Long

    Private _GLRows As GLRows
    Private _InvoiceHeader As InvoiceHeader
    Private _GLAccounts As GLAccounts
    Private _RegistryHeader As RegistryHeader

    Private _DelayedDay As Long
    Private _DelayedRange As String

    Private _ChartOfAccounts_Customers As ChartOfAccounts

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
        ' This constructor is used when an object is loaded from a persistent storage.
        ' Do not place any code here or place it only when the IsLoading property is false:
        ' if (!IsLoading){
        '   It is now OK to place your initialization code here.
        ' }
        ' or as an alternative, move your initialization code into the AfterConstruction method.
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
        ' Place here your initialization code.
        BallanceDEV = 0
        BallanceHUF = 0
        AmountHUF_Account = 0
        AmountDEV_Account = 0
    End Sub

    Property PCIGroup As PCIGroup
        Get
            Return _PCIGroup
        End Get
        Set(value As PCIGroup)
            SetPropertyValue("PCIGroup", _PCIGroup, value)
        End Set
    End Property
    Property MainType As String
        Get
            Return _MainType
        End Get
        Set(value As String)
            SetPropertyValue("MainType", _MainType, value)
        End Set
    End Property
    Property CustomersFrom As CustomersFrom
        Get
            Return _CustomersFrom
        End Get
        Set(value As CustomersFrom)
            SetPropertyValue("CustomersFrom", _CustomersFrom, value)
        End Set
    End Property
    Property Customers As Customers
        Get
            Return _Customers
        End Get
        Set(value As Customers)
            SetPropertyValue("Customers", _Customers, value)
        End Set
    End Property
    Property PartnerType As ePartnerType
        Get
            Return _PartnerType
        End Get
        Set(value As ePartnerType)
            SetPropertyValue("_PartnerType", _PartnerType, value)
        End Set
    End Property
    Property ConnectInfo As String
        Get
            Return _ConnectInfo
        End Get
        Set(value As String)
            SetPropertyValue("ConnectInfo", _ConnectInfo, value)
        End Set
    End Property
    Property DocumentNumber As String
        Get
            Return _DocumentNumber
        End Get
        Set(value As String)
            SetPropertyValue("DocumentNumber", _DocumentNumber, value)
        End Set
    End Property
    Property RegistryNumber As String
        Get
            Return _RegistryNumber
        End Get
        Set(value As String)
            SetPropertyValue("RegistryNumber", _RegistryNumber, value)
        End Set
    End Property
    Property CurrencyName As CurrencyName
        Get
            Return _CurrencyName
        End Get
        Set(value As CurrencyName)
            SetPropertyValue("CurrencyName", _CurrencyName, value)
        End Set
    End Property
    Property CurrencyRate As Double
        Get
            Return _CurrencyRate
        End Get
        Set(value As Double)
            SetPropertyValue("CurrencyRate", _CurrencyRate, value)
        End Set
    End Property
    Property BallanceHUF As Double
        Get
            Return _BallanceHUF
        End Get
        Set(value As Double)
            SetPropertyValue("BallanceHUF", _BallanceHUF, value)
            If Session.IsObjectsSaving = False And Session.IsObjectsLoading = False Then
                If CurrencyName IsNot Nothing Then
                    If CurrencyName.ShortName <> "HUF" Then
                        If BallanceDEV <> 0 Then
                            CurrencyRate = Math.Round(BallanceHUF / BallanceDEV, 2, MidpointRounding.AwayFromZero)
                        Else
                            CurrencyRate = 1
                        End If
                    End If
                Else
                    CurrencyRate = 1
                End If
            Else
                CurrencyRate = 1
            End If
        End Set
    End Property
    Property BallanceDEV As Double
        Get
            Return _BallanceDEV
        End Get
        Set(value As Double)
            SetPropertyValue("BallanceDEV", _BallanceDEV, value)
        End Set
    End Property
    Property DateExecution As Date
        Get
            Return _DateExecution
        End Get
        Set(value As Date)
            SetPropertyValue("DateExecution", _DateExecution, value)
        End Set
    End Property
    Property DateCreated As Date
        Get
            Return _DateCreated
        End Get
        Set(value As Date)
            SetPropertyValue("DateCreated", _DateCreated, value)
        End Set
    End Property

    Property DatePayment_Account As Date
        Get
            Return _DatePayment_Account
        End Get
        Set(value As Date)
            SetPropertyValue("DatePayment_Account", _DatePayment_Account, value)
        End Set
    End Property
    Property DateExecution_Account As Date
        Get
            Return _DateExecution_Account
        End Get
        Set(value As Date)
            SetPropertyValue("DateExecution_Account", _DateExecution_Account, value)
        End Set
    End Property
    Property CurrencyName_Account As CurrencyName
        Get
            Return _CurrencyName_Account
        End Get
        Set(value As CurrencyName)
            SetPropertyValue("CurrencyName_Account", _CurrencyName_Account, value)
        End Set
    End Property
    Property Paymode_Account As ePayMode
        Get
            Return _Paymode_Account
        End Get
        Set(value As ePayMode)
            SetPropertyValue("Paymode_Account", _Paymode_Account, value)
        End Set
    End Property
    Property AmountHUF_Account As Double
        Get
            Return _AmountHUF_Account
        End Get
        Set(value As Double)
            SetPropertyValue("AmountHUF_Account", _AmountHUF_Account, value)
        End Set
    End Property
    Property AmountDEV_Account As Double
        Get
            Return _AmountDEV_Account
        End Get
        Set(value As Double)
            SetPropertyValue("AmountDEV_Account", _AmountDEV_Account, value)
        End Set
    End Property

    Property ShortName As String
        Get
            Return _ShortName
        End Get
        Set(value As String)
            SetPropertyValue("ShortName", _ShortName, value)
        End Set
    End Property
    <Size(-1)> _
    Property Description As String
        Get
            Return _Description
        End Get
        Set(value As String)
            SetPropertyValue("Description", _Description, value)
        End Set
    End Property

    Property BallanceState As Long
        Get
            Return _BallanceState
        End Get
        Set(value As Long)
            SetPropertyValue("BallanceState", _BallanceState, value)
        End Set
    End Property
    Property BallanceRateDiff As Long
        Get
            Return _BallanceRateDiff
        End Get
        Set(value As Long)
            SetPropertyValue("BallanceRateDiff", _BallanceRateDiff, value)
        End Set
    End Property

    Property GLRows As GLRows
        Get
            Return _GLRows
        End Get
        Set(value As GLRows)
            SetPropertyValue("GLRows", _GLRows, value)
        End Set
    End Property
    <Browsable(False), VisibleInListView(False)> _
    Property InvoiceHeader As InvoiceHeader
        Get
            Return _InvoiceHeader
        End Get
        Set(value As InvoiceHeader)
            SetPropertyValue("InvoiceHeader", _InvoiceHeader, value)
        End Set
    End Property
    <Browsable(False)> _
    Property GLAccounts As GLAccounts
        Get
            Return _GLAccounts
        End Get
        Set(value As GLAccounts)
            SetPropertyValue("GLAccounts", _GLAccounts, value)
        End Set
    End Property
    <Browsable(False)> _
    Property RegistryHeader As RegistryHeader
        Get
            Return _RegistryHeader
        End Get
        Set(value As RegistryHeader)
            SetPropertyValue("RegistryHeader", _RegistryHeader, value)
        End Set
    End Property

    Property DelayedDay As Long
        Get
            Return _DelayedDay
        End Get
        Set(value As Long)
            SetPropertyValue("DelayedDay", _DelayedDay, value)
        End Set
    End Property
    Property DelayedRange As String
        Get
            Return _DelayedRange
        End Get
        Set(value As String)
            SetPropertyValue("DelayedRange", _DelayedRange, value)
        End Set
    End Property

    'Property ChartOfAccounts_Customers As ChartOfAccounts
    '    Get
    '        Return _ChartOfAccounts_Customers
    '    End Get
    '    Set(value As ChartOfAccounts)
    '        SetPropertyValue("ChartOfAccounts_Customers", _ChartOfAccounts_Customers, value)
    '    End Set
    'End Property
End Class

