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(False), CreatableItem(False)> _
Public Class AssetsHandling 'Kintlévőség kezelés
    Inherits BaseObject
    Private _QueueIndex As Long = 0 'Hanyadik a sorban
    Private _InvoiceHeader As InvoiceHeader 'Bázis objektum, amihez kapcsolódik
    Private _DateClose As Date 'Záró dátum
    Private _CustomersFrom As CustomersFrom 'Saját cég
    Private _Customers As Customers 'Vevő
    Private _DocumentNumber As String 'Számlaszám
    Private _AmountDEV_Account As Double 'Számla eredeti bruttó végösszege (DEV)
    Private _AmountHUF_Account As Double 'Számla eredeti bruttó végösszege (HUF)
    Private _BalanceHUF As Double 'Egyenleg (nyitott összeg) HUF
    Private _BalanceDEV As Double 'Egyenleg (nyitott összeg) DEV
    Private _DateCreated As Date 'Számla kiáll. dátuma
    Private _DatePayment As Date 'Számla fiz. hat.
    Private _DateExecution As Date 'A fizetési felszólítás dátuma
    Private _DelayedDay As Long 'Késett nap
    Private _Note As String 'Megjegyzés
    Private _IsActive As Boolean = False
    Private _ObjectCreated As Date 'Keletkezés dátuma
    Private _UserCreated As User 'Létrehozó felhasználó
    Private _EMailSendQueueRows As EMailSendQueueRows

    Private _LateChargesBalanceHUF As Double 'Késedelmi kamat összege forintban

    Private _CountLateCharges As Boolean = True 'Számolunk-e késedelmi kamatot
    Private _NoAssetsHandling As Boolean = False 'Nem kell fizetési felszólítás erre a számlára vonatkozólag

    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.
    End Sub
    Protected Overrides Sub OnSaving()
        MyBase.OnSaving()
        If Session.IsNewObject(Me) Then
            ObjectCreated = GetSQLTime(Session)
            If Not SecuritySystem.CurrentUser Is Nothing Then
                _UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser))
            End If
        End If
    End Sub

    Property QueueIndex As Long
        Get
            Return _QueueIndex
        End Get
        Set(ByVal value As Long)
            SetPropertyValue("QueueIndex", _QueueIndex, value)
        End Set
    End Property
    Property InvoiceHeader As InvoiceHeader
        Get
            Return _InvoiceHeader
        End Get
        Set(ByVal value As InvoiceHeader)
            SetPropertyValue("InvoiceHeader", _InvoiceHeader, value)
        End Set
    End Property
    Property DateClose As Date
        Get
            Return _DateClose
        End Get
        Set(value As Date)
            SetPropertyValue("DateClose", _DateClose, 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 DocumentNumber As String
        Get
            Return _DocumentNumber
        End Get
        Set(ByVal value As String)
            SetPropertyValue("DocumentNumber", _DocumentNumber, 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 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 BalanceHUF As Double
        Get
            Return _BalanceHUF
        End Get
        Set(value As Double)
            SetPropertyValue("BalanceHUF", _BalanceHUF, value)
        End Set
    End Property
    Property BalanceDEV As Double
        Get
            Return _BalanceDEV
        End Get
        Set(value As Double)
            SetPropertyValue("BalanceDEV", _BalanceDEV, 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 DateExecution As Date
        Get
            Return _DateExecution
        End Get
        Set(value As Date)
            SetPropertyValue("DateExecution", _DateExecution, value)
        End Set
    End Property
    Property DatePayment As Date
        Get
            Return _DatePayment
        End Get
        Set(value As Date)
            SetPropertyValue("DatePayment", _DatePayment, value)
        End Set
    End Property
    Property Note As String
        Get
            Return _Note
        End Get
        Set(ByVal value As String)
            SetPropertyValue("Note", _Note, value)
        End Set
    End Property
    Property IsActive As Boolean
        Get
            Return _IsActive
        End Get
        Set(ByVal value As Boolean)
            SetPropertyValue("IsActive", _IsActive, value)
        End Set
    End Property
    <NonCloneable> _
    Property ObjectCreated As Date
        Get
            Return _ObjectCreated
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("ObjectCreated", _ObjectCreated, value)
        End Set
    End Property
    <NonCloneable> _
    Property UserCreated As User
        Get
            Return _UserCreated
        End Get
        Set(value As User)
            SetPropertyValue("UserCreated", _UserCreated, value)
        End Set
    End Property
    Property EMailSendQueueRows As EMailSendQueueRows
        Get
            Return _EMailSendQueueRows
        End Get
        Set(value As EMailSendQueueRows)
            SetPropertyValue("EMailSendQueueRows", _EMailSendQueueRows, value)
        End Set
    End Property

    Property CountLateCharges As Boolean
        Get
            Return _CountLateCharges
        End Get
        Set(value As Boolean)
            SetPropertyValue("CountLateCharges", _CountLateCharges, value)
        End Set
    End Property
    Property NoAssetsHandling As Boolean
        Get
            Return _NoAssetsHandling
        End Get
        Set(value As Boolean)
            SetPropertyValue("NoAssetsHandling", _NoAssetsHandling, value)
        End Set
    End Property

    Property LateChargesBalanceHUF As Double
        Get
            Return _LateChargesBalanceHUF
        End Get
        Set(value As Double)
            SetPropertyValue("LateChargesBalanceHUF", _LateChargesBalanceHUF, value)
        End Set
    End Property

    <Association("AssetsHandlin-AssetsHandlingPCI", GetType(AssetsHandlingPCI)), VisibleInListView(False)> _
    ReadOnly Property AssetsHandlingPCI As XPCollection(Of AssetsHandlingPCI)
        Get
            Return GetCollection(Of AssetsHandlingPCI)("AssetsHandlingPCI")
        End Get
    End Property
End Class
