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.ExpressApp.ConditionalAppearance
Imports System.Linq
Imports System.Linq.Expressions

Imports DevExpress.ExpressApp.Editors

'<EditorStateRuleAttribute("Hide reinvoice info", "ReInvoiceMode;ReInvoice_ExtraCharge;ReInvoice_Customers;ReInvoice_ContractRows;ReInvoiceReason", EditorState.Hidden, "IsReInvoice=False", ViewType.DetailView)> _
'<EditorStateRuleAttribute("Hide reinvoice info 2", "ReInvoice_ExtraCharge;ReInvoice_Customers;ReInvoice_ContractRows;ReInvoiceReason", EditorState.Hidden, "ReInvoiceMode=2", ViewType.DetailView)> _
'<EditorStateRuleAttribute("Hide reinvoice info 3", "ReInvoice_ExtraCharge;ReInvoice_Customers;ReInvoice_ContractRows;ReInvoiceReason", EditorState.Hidden, "ReInvoiceMode=0", ViewType.DetailView)> _
'<EditorStateRuleAttribute("Hide contractrows when from COC", "Contracts;ContractRows", EditorState.Hidden, "ChoiceRowMode=1", ViewType.DetailView)> _
'<EditorStateRuleAttribute("Disable properties in RegistryRowsFinancialControlling", "RegistryHeader;UniqueObjects;JobNumberObjects;ChoiceRowMode;Controlling;ChartOfAccounts;Contracts;ContractRows;PaymentOption;Note;Amount;CostHolder;CostPlace;IsReInvoice;ReInvoiceReason;ReInvoice_Customers;ReInvoice_ContractRows;ReInvoice_ExtraCharge;IsGuaranteeBack;ReInvoiceMode", _
'                           ViewType.DetailView, "RegistryHeader.CurrentWorkflowSystemSteps.StepFinancialType in (2,5) = False", EditorState.Disabled)> _
'<EditorStateRuleAttribute("Disable properties in RegistryRowsFinancialControlling2", "*", ViewType.DetailView, "RegistryHeader.CurrentWorkflowSystemSteps.StepIndex>4", EditorState.Disabled)> _

<DefaultClassOptions()> _
<NavigationItem(False), CreatableItem(False)> _
<DefaultProperty("DisplayName")> _
<Appearance("Hide reinvoice info", TargetItems:="ReInvoiceMode;ReInvoice_ExtraCharge;ReInvoice_Customers;ReInvoice_ContractRows;ReInvoiceReason", Criteria:="IsReInvoice=False", Visibility:=Editors.ViewItemVisibility.Hide, Context:="DetailView")> _
<Appearance("Hide reinvoice info 2", TargetItems:="ReInvoice_ExtraCharge;ReInvoice_Customers;ReInvoice_ContractRows;ReInvoiceReason", Criteria:="ReInvoiceMode=2", Visibility:=Editors.ViewItemVisibility.Hide, Context:="DetailView")> _
<Appearance("Hide reinvoice info 3", TargetItems:="ReInvoice_ExtraCharge;ReInvoice_Customers;ReInvoice_ContractRows;ReInvoiceReason", Criteria:="ReInvoiceMode=0", Visibility:=Editors.ViewItemVisibility.Hide, Context:="DetailView")> _
<Appearance("Hide contractrows when from COC", TargetItems:="Contracts;ContractRows", Criteria:="ChoiceRowMode=1", Visibility:=Editors.ViewItemVisibility.Hide, Context:="DetailView")> _
<Appearance("Disable properties in RegistryRowsFinancialControlling", TargetItems:="RegistryHeader;UniqueObjects;JobNumberObjects;ChoiceRowMode;Controlling;ChartOfAccounts;Contracts;ContractRows;PaymentOption;Note;Amount;CostHolder;CostPlace;IsReInvoice;ReInvoiceReason;ReInvoice_Customers;ReInvoice_ContractRows;ReInvoice_ExtraCharge;IsGuaranteeBack;ReInvoiceMode", _
    Criteria:="RegistryHeader.CurrentWorkflowSystemSteps.StepFinancialType in (2,5) = False", Enabled:=False, Context:="DetailView")> _
<Appearance("Disable properties in RegistryRowsFinancialControlling2", TargetItems:="*", Criteria:="RegistryHeader.CurrentWorkflowSystemSteps.StepIndex>4", Enabled:=False, Context:="DetailView")> _
<Appearance("HIDE aCreateTechnicalContractFromRegistry StepIndex>3", AppearanceItemType.Action, _
            "(RegistryHeader.CurrentWorkflowSystemSteps.StepFinancialType in (2,5) = False) Or !IsNull(ContractRows) Or ! IsNull(Contracts)", _
            TargetItems:="aCreateTechnicalContractFromRegistry", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("HIDE aCreateContracts", AppearanceItemType.Action, "ChoiceRowMode=1", TargetItems:="aCreateContracts", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("HIDE aCreateContractsRowsfromControllingRows", AppearanceItemType.Action, "ChoiceRowMode=1 or IsNull(Contracts)", TargetItems:="aCreateContractsRowsfromControllingRows", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("HIDE aCreateTechnicalContractFromRegistry", AppearanceItemType.Action, "ChoiceRowMode=1", TargetItems:="aCreateTechnicalContractFromRegistry", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("HIDE @COCManipulation", AppearanceItemType.LayoutItem, "ChoiceRowMode=1", TargetItems:="@COCManipulation", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("HIDE aGenerateCOC", AppearanceItemType.Action, "ChoiceRowMode=1", TargetItems:="aGenerateCOC", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("HIDE ContractRows", AppearanceItemType.ViewItem, "isnull(Contracts)=True", TargetItems:="ContractRows", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide RegistryBankTransfer_Group when IsGuaranteeBack = false", AppearanceItemType.LayoutItem, "IsGuaranteeBack = False", TargetItems:="RegistryBankTransfer_Group", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide RegistryBankTransfer_Group when RegistryHeader.F_PayMode!=1", AppearanceItemType.ViewItem, "RegistryHeader.F_PayMode!=1", TargetItems:="IsGuaranteeBack", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Disable actions if currentstep is not eCheckControlling", AppearanceItemType:="Action", Criteria:="RegistryHeader.CurrentWorkflowSystemSteps.StepFinancialType In (2,3,5) = False ", TargetItems:="Save;SaveAndNew;SaveAndClose;Delete", Enabled:=False, Context:="Any")> _
<Appearance("HIDE New action - RegistryRowsFinancialControlling", AppearanceItemType:="Action", TargetItems:="New", Enabled:=False, Criteria:="RegistryHeader.NettoAmountRemaining=0 and isnull(RegistryHeader.NettoAmountRemaining)=False", Context:="Any")> _
<RuleCriteria("RuleCriteria RegistryRowsFinancialControlling-Controlling", DefaultContexts.Save, _
        "(Controlling.IsParent=False) or (RegistryHeader.RegistryType.Rule5DMatrix.RequireControlling=False and isnull(Controlling)=True)", _
    "Gyüjtő kontrollszám nem választható ki!", SkipNullOrEmptyValues:=False)> _
<RuleCriteria("RuleCriteria RegistryRowsFinancialControlling-Controlling-II", "aCreateContractsRowsfromControllingRows", _
    "(Controlling.IsParent=False) or (RegistryHeader.RegistryType.Rule5DMatrix.RequireControlling=False and isnull(Controlling)=True)", _
    "Gyüjtő kontrollszám nem választható ki!", SkipNullOrEmptyValues:=False)> _
Public Class RegistryRowsFinancialControlling
    Inherits BaseObject
    Private _RegistryHeader As RegistryHeader 'Iktatás fejléce 
    Private _ChoiceRowMode As eChoiceRowMode 'Szerződési sor vagy teljesítési igazolás sor kiválasztása
    Private _DateExecution As Date 'Teljesítés dátuma
    Private _ChartOfAccounts As ChartOfAccounts 'FK által beállított számlaszám <NonCloneable()> _
    Private _Contracts As Contracts 'Szerződés fejléce<NonCloneable()> _
    Private _ContractRows As ContractRows 'Szerződési sor<NonCloneable()> _
    Private _PaymentOption As PaymentOption 'Fizetési mód
    Private _Note As String 'Megjegyzés
    Private _Amount As Double 'Nettó összeg<NonCloneable()> _

    Private _Controlling As Controlling 'Kontroll szám
    Private _CostHolder As CostHolder 'Költségviselő
    Private _CostPlace As CostPlace 'Költséghely
    Private _UniqueObjects As UniqueObjects 'Egyedi azonosító
    Private _JobNumberObjects As JobNumberObjects 'Munkaszám, project

    Private _File As FileData 'A beszkennelt telj. igazolás file<NonCloneable()> _
    Private _IsReInvoice As Boolean '= False 'Tovább kell számlázni ?
    Private _ReInvoice_Customers As Customers 'Kinek kell továbbszámlázni ?
    Private _ReInvoice_ContractRows As ContractRows 'Milyen szerződési sor alapján <NonCloneable()> _
    Private _ReInvoice_ExtraCharge As Double 'Mennyiért
    Private _ReInvoice_Contracts As Contracts 'Melyik szerződésre hozza létre a sort amin ki lesz számlázva <NonCloneable()> _
    Private _ReInvoiceMode As eReinvoiceMode 'Továbbszámlázás módja
    Private _ReInvoiceReason As Controlling 'Továbbszámlázás jogcíme
    Private _IsGuaranteeBack As Boolean '= False 'Van-e visszatartási garancia
    Private _F_ReadyforBookEntryRows As Boolean '= False '<NonCloneable()> _
    Private _WorkflowMessage As String 'Léptetéskori üzenet<NonCloneable()> _

    Private _ConnectInfoAdvanced As String = "" 'Analitikus kötési szám az előlegek pontozásához
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
        Me.ChoiceRowMode = eChoiceRowMode.eFromContractRows
        If Me.RegistryHeader IsNot Nothing Then
            Me.DateExecution = Me.RegistryHeader.F_DateExecution
        End If
        IsGuaranteeBack = False
        F_ReadyforBookEntryRows = False
        IsReInvoice = False
    End Sub
    Protected Overrides Sub OnSaving()
        MyBase.OnSaving()
        If IsDeleted = False Then
            If Me.ContractRows IsNot Nothing Then
                Dim _CurrencyRate As Double = 1.0

                If Math.Abs(Me.ContractRows.NettoPriceHUF) < Math.Abs(Me.Amount) Then
                    If Math.Abs(Math.Abs(Me.ContractRows.NettoPriceHUF) - Math.Abs(Me.Amount)) > 5 Then
                        Throw New Exception("*A leigazolni kívánt összeg meghaladja, az igazoláshoz felhasznált szerződési sor összegét, módosítsa a szerződési sort ! Iktatószám : " & Me.RegistryHeader.DocumentNumber)
                    End If
                End If
                If Math.Abs(Me.ContractRows.NettoPriceHUF) > Math.Abs(Me.Amount) Then
                    If Math.Abs(Math.Abs(Me.ContractRows.NettoPriceHUF) - Math.Abs(Me.Amount)) > 5 Then
                        Throw New Exception("*A leigazoláshoz felhasználni kívánt szerződési sor összege meghaladja a számla sor összegét. Módosítsa a szerződési sort ! Iktatószám : " & Me.RegistryHeader.DocumentNumber)
                    End If
                End If
            End If
            If Me.RegistryHeader IsNot Nothing Then
                If Me.DateExecution = Nothing Then
                    Me.DateExecution = Me.RegistryHeader.F_DateExecution
                End If
            End If
        End If
    End Sub
    Protected Overrides Sub OnDeleting()
        MyBase.OnDeleting()
        If Me.ContractRows IsNot Nothing Then
            If Me.ContractRows.Contracts.ContractTemplate.IsTechnical Then
                Me.ContractRows.Delete()
            End If
            If Me.ContractRows IsNot Nothing Then
                Me.ContractRows.RegistryRowsFinancialControlling = Nothing
            End If
        End If
        Dim _DeliveryNoteInRRFC_Collection As New XPCollection(Of DeliveryNoteInRRFC)(PersistentCriteriaEvaluationBehavior.InTransaction, Session, CriteriaOperator.Parse("RegistryRowsFinancialControlling=?", Me))
        Session.Delete(_DeliveryNoteInRRFC_Collection)
    End Sub
    <Association("RegistryHeader-RegistryRowsFinancialControlling", GetType(RegistryHeader))> _
    Property RegistryHeader As RegistryHeader
        Get
            Return _RegistryHeader
        End Get
        Set(ByVal value As RegistryHeader)
            SetPropertyValue("RegistryHeader", _RegistryHeader, value)
            If Session.IsNewObject(Me) And Session.IsObjectsLoading = False And Session.IsObjectsSaving = False And Me.RegistryHeader IsNot Nothing Then
                Me.Note = RegistryHeader.ShortName
            End If
        End Set
    End Property
    <ImmediatePostData(True)> _
    Property ChoiceRowMode As eChoiceRowMode
        Get
            Return _ChoiceRowMode
        End Get
        Set(ByVal value As eChoiceRowMode)
            SetPropertyValue("ChoiceRowMode", _ChoiceRowMode, value)
        End Set
    End Property
    Property DateExecution As Date
        Get
            Return _DateExecution.Date
        End Get
        Set(value As Date)
            SetPropertyValue("DateExecution", _DateExecution, value.Date)
        End Set
    End Property
    Property ConnectInfoAdvanced As String
        Get
            Return _ConnectInfoAdvanced
        End Get
        Set(value As String)
            SetPropertyValue("ConnectInfoAdvanced", _ConnectInfoAdvanced, value)
        End Set
    End Property

    '-Rule5DMatrix -------------------------------
    <RuleRequiredField("RegistryRowsFinancialControlling-Controlling", DefaultContexts.Save, targetcriteria:="RegistryHeader.RegistryType.Rule5DMatrix.RequireControlling")> _
    <RuleRequiredField("RegistryRowsFinancialControlling-Controlling_2", "aCreateContractsRowsfromControllingRows", targetcriteria:="RegistryHeader.RegistryType.Rule5DMatrix.RequireControlling")> _
    Property Controlling As Controlling
        Get
            Return _Controlling
        End Get
        Set(ByVal value As Controlling)
            SetPropertyValue("Controlling", _Controlling, value)
            If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving And Me.ContractRows IsNot Nothing Then
                If Me.ContractRows.Controlling IsNot value Then
                    Me.ContractRows.Controlling = value
                    Me.ContractRows.Save()
                End If
            End If
        End Set
    End Property
    <RuleRequiredField("RegistryRowsFinancialControlling-CostHolder", "aCreateContractsRowsfromControllingRows", targetcriteria:="RegistryHeader.RegistryType.Rule5DMatrix.RequireCostHolder")> _
    Property CostHolder As CostHolder
        Get
            Return _CostHolder
        End Get
        Set(ByVal value As CostHolder)
            SetPropertyValue("CostHolder", _CostHolder, value)
            If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving And Me.ContractRows IsNot Nothing Then
                If Me.ContractRows.CostHolder IsNot value Then
                    Me.ContractRows.CostHolder = value
                    Me.ContractRows.Save()
                End If
            End If
        End Set
    End Property
    <RuleRequiredField("RegistryRowsFinancialControlling-CostPlace", "aCreateContractsRowsfromControllingRows", targetcriteria:="RegistryHeader.RegistryType.Rule5DMatrix.RequireCostPlace")> _
    Property CostPlace As CostPlace
        Get
            Return _CostPlace
        End Get
        Set(ByVal value As CostPlace)
            SetPropertyValue("CostPlace", _CostPlace, value)
        End Set
    End Property
    <RuleRequiredField("RegistryRowsFinancialControlling-UniqueObjects", "aCreateContractsRowsfromControllingRows", targetcriteria:="RegistryHeader.RegistryType.Rule5DMatrix.RequireUniqueObjects")> _
    Property UniqueObjects As UniqueObjects
        Get
            Return _UniqueObjects
        End Get
        Set(ByVal value As UniqueObjects)
            SetPropertyValue("UniqueObjects", _UniqueObjects, value)
            If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving And Me.ContractRows IsNot Nothing Then
                If Me.ContractRows.UniqueObjects IsNot value Then
                    Me.ContractRows.UniqueObjects = value
                    Me.ContractRows.Save()
                End If
            End If
        End Set
    End Property
    <RuleRequiredField("RegistryRowsFinancialControlling-JobNumberObjects", "aCreateContractsRowsfromControllingRows", targetcriteria:="RegistryHeader.RegistryType.Rule5DMatrix.RequireJobNumberObjects")> _
    Property JobNumberObjects As JobNumberObjects
        Get
            Return _JobNumberObjects
        End Get
        Set(ByVal value As JobNumberObjects)
            SetPropertyValue("JobNumberObjects", _JobNumberObjects, value)
            If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving And Me.ContractRows IsNot Nothing Then
                If Me.ContractRows.JobNumberObjects IsNot value Then
                    Me.ContractRows.JobNumberObjects = value
                    Me.ContractRows.Save()
                End If
            End If
        End Set
    End Property


    <NonCloneable()>
    <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
    <NonPersistent()>
    <NonCloneable()>
    <ImmediatePostData(True), DataSourceCriteria("ContractTemplate.PartnerType=1 and Customers='@This.RegistryHeader.Customers' and CustomersFrom ='@This.RegistryHeader.CustomersFrom' AND ContractTemplate.IsTechnical=False AND (State = 1 OR State = 2)")>
    Property Contracts As Contracts
        Get
            Return (_Contracts)
        End Get
        Set(ByVal value As Contracts)
            SetPropertyValue("Contracts", _Contracts, value)
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("Contracts='@This.Contracts' AND IsNull(RegistryRowsFinancialControlling)=TRue and CurrencyName.ShortName='@This.RegistryHeader.F_CurrencyName.ShortName'")>
    <RuleRequiredField("RegistryRowsFinancialControlling.ContractRows", DefaultContexts.Save)>
    <NonCloneable()>
    Property ContractRows As ContractRows
        Get
            Return _ContractRows
        End Get
        Set(ByVal value As ContractRows)
            SetPropertyValue("ContractRows", _ContractRows, value)
            If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then
                If value IsNot Nothing Then
                    PaymentOption = value.PaymentOption
                    Controlling = value.Controlling
                    UniqueObjects = value.UniqueObjects
                    Note = value.Description
                    CostHolder = value.CostHolder
                    CostPlace = value.CostPlace
                    JobNumberObjects = value.JobNumberObjects

                    If Me.RegistryHeader.F_CurrencyName.ShortName <> "HUF" Then
                        Me.Amount = Math.Round(value.NettoPriceDEV * Me.RegistryHeader.F_CurrencyRate, 0, MidpointRounding.AwayFromZero)
                        value.NettoPriceHUF = Math.Round(value.NettoPriceDEV * Me.RegistryHeader.F_CurrencyRate, 0, MidpointRounding.AwayFromZero)
                        '-- Itt van egy SAVE !!!!! De ez kell !!!!!!
                        value.Save()
                    Else
                        Me.Amount = value.NettoPriceHUF
                    End If
                End If
            End If
        End Set
    End Property
    Property PaymentOption As PaymentOption
        Get
            Return _PaymentOption
        End Get
        Set(ByVal value As PaymentOption)
            SetPropertyValue("PaymentOption", _PaymentOption, value)
        End Set
    End Property
    Property Note As String
        Get
            Return _Note
        End Get
        Set(ByVal value As String)
            SetPropertyValue("Note", _Note, value)
            If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving And Me.ContractRows IsNot Nothing Then
                'If Not Me.ContractRows.ShortName = value Then
                '    Me.ContractRows.ShortName = value
                '    Me.ContractRows.Save()
                'End If
            End If
        End Set
    End Property
    <NonCloneable()>
    Property Amount As Double
        Get
            Return _Amount
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("Amount", _Amount, value)
            If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving And Me.ContractRows IsNot Nothing Then
                If Me.ContractRows.NettoPriceHUF = value Then
                    Me.ContractRows.NettoPriceHUF = value
                    Me.ContractRows.NettoPriceHUF = Math.Round(Me.ContractRows.NettoPriceHUF, 2, MidpointRounding.AwayFromZero)
                End If
                value = Math.Round(value, 2, MidpointRounding.AwayFromZero)
            End If
        End Set
    End Property
    <NonCloneable()>
    Property File As FileData
        Get
            Return _File
        End Get
        Set(ByVal value As FileData)
            SetPropertyValue("File", _File, value)
        End Set
    End Property
    <ImmediatePostData(True)>
    Property IsReInvoice As Boolean
        Get
            Return _IsReInvoice
        End Get
        Set(ByVal value As Boolean)
            SetPropertyValue("IsReInvoice", _IsReInvoice, value)
        End Set
    End Property
    <ImmediatePostData(True)>
    <RuleValueComparison("RegistryRowsFinancialControlling.ReInvoiceMode", DefaultContexts.Save, ValueComparisonType.NotEquals, eReinvoiceMode.eNotSet, TargetCriteria:="IsReInvoice = True")>
    Property ReInvoiceMode As eReinvoiceMode
        Get
            Return _ReInvoiceMode
        End Get
        Set(ByVal value As eReinvoiceMode)
            SetPropertyValue("ReinvoiceMode", _ReInvoiceMode, value)
            If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then
            End If
        End Set
    End Property
    <RuleRequiredField("RegistryRowsFinancialControlling", DefaultContexts.Save, TargetCriteria:="IsReInvoice=True AND ReInvoiceMode=1")>
    <ImmediatePostData(True), DataSourceCriteria("Controllingdirection = 0 And IsReInvoiceReason = True")>
    Property ReInvoiceReason As Controlling
        Get
            Return _ReInvoiceReason
        End Get
        Set(ByVal value As Controlling)
            SetPropertyValue("ReInvoiceReason", _ReInvoiceReason, value)
        End Set
    End Property
    Property ReInvoice_Customers As Customers
        Get
            Return _ReInvoice_Customers
        End Get
        Set(ByVal value As Customers)
            SetPropertyValue("ReInvoice_Customers", _ReInvoice_Customers, value)
        End Set
    End Property
    <NonCloneable()>
    <ImmediatePostData(True), DataSourceCriteria("Contracts.CustomersFrom = '@This.RegistryHeader.CustomersFrom' And Contracts.Customers = '@This.ReInvoice_Customers' And Contracts.ContractTemplate.PartnerType = 0")>
    Property ReInvoice_ContractRows As ContractRows
        Get
            Return _ReInvoice_ContractRows
        End Get
        Set(ByVal value As ContractRows)
            SetPropertyValue("ReInvoice_ContractRows", _ReInvoice_ContractRows, value)
        End Set
    End Property
    Property ReInvoice_ExtraCharge As Double
        Get
            Return _ReInvoice_ExtraCharge
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("ReInvoice_ExtraCharge", _ReInvoice_ExtraCharge, value)
        End Set
    End Property
    <ImmediatePostData()> _
    Property IsGuaranteeBack As Boolean
        Get
            Return _IsGuaranteeBack
        End Get
        Set(ByVal value As Boolean)
            SetPropertyValue("IsGuaranteeBack", _IsGuaranteeBack, value)
        End Set
    End Property
    <NonCloneable()> _
    Property F_ReadyforBookEntryRows As Boolean
        Get
            Return _F_ReadyforBookEntryRows
        End Get
        Set(ByVal value As Boolean)
            SetPropertyValue("F_ReadyforBookEntryRows", _F_ReadyforBookEntryRows, value)
        End Set
    End Property
    <NonCloneable()> _
    <VisibleInDetailView(False), VisibleInListView(False), VisibleInLookupListView(False), Size(-1)>
    Property WorkflowMessage As String
        Get
            Return _WorkflowMessage
        End Get
        Set(ByVal value As String)
            SetPropertyValue("WorkflowMessage", _WorkflowMessage, value)
        End Set
    End Property

    '------ReadOnly----------
    <VisibleInListView(False)> _
    ReadOnly Property RegistryBankTransfer As XPCollection(Of RegistryBankTransfer)
        Get
            Return New XPCollection(Of RegistryBankTransfer)(Session, CriteriaOperator.Parse("RegistryHeader=?", Me.RegistryHeader))
        End Get
    End Property
    ReadOnly Property DisplayName As String
        Get
            If Me.RegistryHeader IsNot Nothing Then
                Return Me.RegistryHeader.RegistryNumber & ", " & Me.RegistryHeader.DocumentNumber
            Else
                Return ""
            End If
        End Get
    End Property
End Class

