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("FinancialTransactions")> _
<ImageName("BO_Report")> _
<DeferredDeletion(False)> _
<Appearance("Disable UserCreated,ObjectCreated-VATReport", AppearanceItemType:="ViewItem", Enabled:=False, TargetItems:="ObjectCreated,UserCreated", Criteria:="1=1")> _
<Appearance("Hide aVATClose when Closed", AppearanceItemType:="Action", TargetItems:="aVATClose", Criteria:="Closed = True", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide aVATCloseBack when not Closed", AppearanceItemType:="Action", TargetItems:="aVATCloseBack", Criteria:="Closed != True", visibility:=Editors.ViewItemVisibility.Hide)> _
Public Class VATReport
    Inherits BaseObject
    Private _ShortName As String 'Megnevezés pld 2011 jaunári áfa
    Private _DateFrom As Date 'Dátumtól
    Private _DateTo As Date 'Dátumig
    Private _DateVAT As Date 'ÁFA dátum, amikor a bevallás kell
    Private _CustomersFrom As CustomersFrom ' Saját cég
    Private _OnlyVAT As Boolean = True
    Private _TotalAmountIn As Double ' Öszes beszerzést terhelő ÁFA
    Private _TotalAmountOut As Double ' Összes értékesítést terhelő ÁFA
    Private _DifferenceAmount As Double 'Értékesítést terhelő - Beszerzést terhelő
    Private _ObjectCreated As Date
    Private _UserCreated As User
    Private _GLClosingTime As GLClosingTime
    Private _Closed As Boolean = False
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Protected Overrides Sub OnSaving()
        MyBase.OnSaving()
        If Session.IsNewObject(Me) Then
            ObjectCreated = GetSQLTime(Session)
            UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser))
        End If
        DifferenceAmount = TotalAmountOut - TotalAmountIn
    End Sub
    <RuleRequiredField("VATReport-ShortName", "aGenerateVATReport_Contexts")> _
    <RuleRequiredField("VATReport-ShortName-Save", DefaultContexts.Save)> _
    Property ShortName As String
        Get
            Return _ShortName
        End Get
        Set(ByVal value As String)
            SetPropertyValue("ShortName", _ShortName, value)
        End Set
    End Property
    <RuleRequiredField("VATReport-DateFrom", "aGenerateVATReport_Contexts")> _
    <RuleRequiredField("VATReport-DateFrom-Save", DefaultContexts.Save)> _
    Property DateFrom As Date
        Get
            Return _DateFrom
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("DateFrom", _DateFrom, value)
        End Set
    End Property
    <RuleRequiredField("VATReport-DateTo", "aGenerateVATReport_Contexts")> _
    <RuleRequiredField("VATReport-DateTo-Save", DefaultContexts.Save)> _
    Property DateTo As Date
        Get
            Return _DateTo
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("DateTo", _DateTo, value)
        End Set
    End Property
    <RuleRequiredField("VATReport-DateVAT", "aGenerateVATReport_Contexts")> _
    <RuleRequiredField("VATReport-DateVAT-Save", DefaultContexts.Save)> _
    Property DateVAT As Date
        Get
            Return _DateVAT
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("DateVAT", _DateVAT, value)
        End Set
    End Property
    <RuleRequiredField("VATReport-CustomersFrom", DefaultContexts.Save)> _
    Property CustomersFrom As CustomersFrom
        Get
            Return _CustomersFrom
        End Get
        Set(ByVal value As CustomersFrom)
            SetPropertyValue("CustomersFrom", _CustomersFrom, value)
        End Set
    End Property
    Property OnlyVAT As Boolean
        Get
            Return _OnlyVAT
        End Get
        Set(ByVal value As Boolean)
            SetPropertyValue("OnlyVAT", _OnlyVAT, value)
        End Set
    End Property
    Property TotalAmountIn As Double
        Get
            Return _TotalAmountIn
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("TotalAmountIn", _TotalAmountIn, value)
        End Set
    End Property
    Property TotalAmountOut As Double
        Get
            Return _TotalAmountOut
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("TotalAmountOut", _TotalAmountOut, value)
        End Set
    End Property
    Property DifferenceAmount As Double
        Get
            Return _DifferenceAmount
        End Get
        Set(value As Double)
            SetPropertyValue("DifferenceAmount", _DifferenceAmount, value)
        End Set
    End Property
    <NonCloneable> _
    Property ObjectCreated As Date
        Get
            Return _ObjectCreated
        End Get
        Set(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
    <Browsable(False)> _
    Property GLClosingTime As GLClosingTime
        Get
            Return _GLClosingTime
        End Get
        Set(value As GLClosingTime)
            SetPropertyValue("GLClosingTime", _GLClosingTime, value)
        End Set
    End Property
    Property Closed As Boolean
        Get
            Return _Closed
        End Get
        Set(value As Boolean)
            SetPropertyValue("Closed", _Closed, value)
        End Set
    End Property

    <Association("VATReport-VATReportGroup", GetType(VATReportGroup)), Aggregated(), VisibleInListView(False)> _
    ReadOnly Property VATReportGroup As XPCollection(Of VATReportGroup)
        Get
            Return GetCollection(Of VATReportGroup)("VATReportGroup")
        End Get
    End Property
    <Association("VATReport-VATReportDetail", GetType(VATReportDetail)), Aggregated(), VisibleInListView(False)> _
    ReadOnly Property VATReportDetail As XPCollection(Of VATReportDetail)
        Get
            Return GetCollection(Of VATReportDetail)("VATReportDetail")
        End Get
    End Property
    <Association("VATReport-VATReportGroupCustomers2M", GetType(VATReportGroupCustomers2M)), Aggregated(), VisibleInListView(False)> _
    ReadOnly Property VATReportGroupCustomers2M As XPCollection(Of VATReportGroupCustomers2M)
        Get
            Return GetCollection(Of VATReportGroupCustomers2M)("VATReportGroupCustomers2M")
        End Get
    End Property
    <Association("VATReport-VATReportNoPayDetail", GetType(VATReportNoPayDetail)), Aggregated(), VisibleInListView(False)> _
    ReadOnly Property VATReportNoPayDetail As XPCollection(Of VATReportNoPayDetail)
        Get
            Return GetCollection(Of VATReportNoPayDetail)("VATReportNoPayDetail")
        End Get
    End Property
    <Association("VATReport-VATReportFileAttachment", GetType(VATReportFileAttachment)), Aggregated(), VisibleInListView(False)> _
    ReadOnly Property VATReportFileAttachment As XPCollection(Of VATReportFileAttachment)
        Get
            Return GetCollection(Of VATReportFileAttachment)("VATReportFileAttachment")
        End Get
    End Property

    <Association("VATReport-VATReport07", GetType(VATReport07))> _
    ReadOnly Property VATReport07 As XPCollection(Of VATReport07)
        Get
            Return GetCollection(Of VATReport07)("VATReport07")
        End Get
    End Property
    <Association("VATReport-VATReport08", GetType(VATReport08))> _
    ReadOnly Property VATReport08 As XPCollection(Of VATReport08)
        Get
            Return GetCollection(Of VATReport08)("VATReport08")
        End Get
    End Property
    
End Class

