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)> _
<NonPersistent()> _
Public Class DivideVAT
    Inherits BaseObject

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
        If Me.RegistryRowsFinancial IsNot Nothing Then
            VAT = Me.RegistryRowsFinancial.VAT
            DateVAT = Me.RegistryRowsFinancial.DateVAT
        End If
    End Sub

    Private _RegistryRowsFinancial As RegistryRowsFinancial
    Private _AmountPercent As Double
    Private _BruttoAmount As Double
    Private _VAT As VAT
    Private _DateVAT As Date
    Private _Note As String

    <Browsable(False)> _
    Property RegistryRowsFinancial As RegistryRowsFinancial
        Get
            Return _RegistryRowsFinancial
        End Get
        Set(value As RegistryRowsFinancial)
            SetPropertyValue("RegistryRowsFinancial", _RegistryRowsFinancial, value)
        End Set
    End Property
    <RuleRange("DivideVAT-AmountPercent", DefaultContexts.Save, 0, 99)> _
    <ImmediatePostData()> _
    Property AmountPercent As Double
        Get
            Return _AmountPercent
        End Get
        Set(value As Double)
            SetPropertyValue("AmountPercent", _AmountPercent, value)
            If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then
                Me.BruttoAmount = RegistryRowsFinancial.BruttoAmount * (value / 100)
            End If
        End Set
    End Property
    Property BruttoAmount As Double
        Get
            Return _BruttoAmount
        End Get
        Set(value As Double)
            SetPropertyValue("BruttoAmount", _BruttoAmount, value)
        End Set
    End Property
    Property VAT As VAT
        Get
            Return _VAT
        End Get
        Set(value As VAT)
            SetPropertyValue("VAT", _VAT, value)
        End Set
    End Property
    Property DateVAT As Date
        Get
            Return _DateVAT
        End Get
        Set(value As Date)
            SetPropertyValue("DateVAT", _DateVAT, value)
        End Set
    End Property
    <Size(-1)> _
    Property Note As String
        Get
            Return _Note
        End Get
        Set(value As String)
            SetPropertyValue("Note", _Note, value)
        End Set
    End Property

End Class
