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 ' _ ' _ ' _ ' _ ' _ ' _ ' _ ' _ _ _ _ _ _ _ _ _ _ _ _ _ _ Public Class GLCompensation Inherits GLHeader Private _PartnerType As ePartnerType Private _TransactionType As eTransactionType Private _ChartOfAccounts As ChartOfAccounts Private _TotalInAmountHUF As Double = 0 Private _TotalOutAmountHUF As Double = 0 Private _TotalInAmountDEV As Double = 0 Private _TotalOutAmountDEV As Double = 0 Private _LiquidAssets As LiquidAssets Private _BallanceHUF As Double Private _BallanceDEV As Double Private _PCIGroup As PCIGroup Private _GLHeader_RateDiff As GLHeader 'Kapcsolódó árf. kül. elszámolási vegyes bizonylat '-- A másodlagos Private _row_AmountDEV2 As Double = 0 Private _row_CurrencyRate2 As Double = 1 Private _row_CurrencyName2 As CurrencyName Public Sub New(ByVal session As Session) MyBase.New(session) End Sub Public Overrides Sub AfterConstruction() MyBase.AfterConstruction() If Session.IsNewObject(Me) Then Me.GLDocumentType = eGLDocumentType.eGLCompensation End Sub _ _ Property row_PartnerType() As ePartnerType Get Return _PartnerType End Get Set(ByVal value As ePartnerType) SetPropertyValue("row_PartnerType", _PartnerType, value) End Set End Property _ _ _ Property row_TransactionType() As eTransactionType Get Return _TransactionType End Get Set(ByVal value As eTransactionType) SetPropertyValue("row_TransactionType", _TransactionType, value) If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then Select Case value Case eTransactionType.eNormalCredit, eTransactionType.eNormalDebit, eTransactionType.eNotSet row_CurrencyName2 = LiquidAssets_Main.CurrencyName End Select Select Case value Case eTransactionType.eNormalCredit, eTransactionType.eNormalDebit, eTransactionType.eNotSet Me.row_PartnerType = ePartnerType.eNotSet End Select End If End Set End Property Property row_ChartOfAccounts() As ChartOfAccounts Get Return _ChartOfAccounts End Get Set(ByVal value As ChartOfAccounts) SetPropertyValue("row_ChartOfAccounts", _ChartOfAccounts, value) End Set End Property Property row_PCIGroup() As PCIGroup Get Return _PCIGroup End Get Set(ByVal value As PCIGroup) SetPropertyValue("row_PCIGroup", _PCIGroup, value) If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then If value IsNot Nothing Then row_ConnectInfo = value.ConnectInfo row_Customer = value.Customers row_PartnerType = value.PartnerType If value.CurrencyName_Account.ShortName = "HUF" Then If Me.CurrencyName.ShortName = "HUF" Then Me.row_AmountHUF = Math.Abs(value.BallanceHUF) row_CurrencyName2 = Session.FindObject(Of CurrencyName)(CriteriaOperator.Parse("ShortName='HUF'")) Else row_CurrencyName2 = Session.FindObject(Of CurrencyName)(CriteriaOperator.Parse("ShortName='HUF'")) End If Else If Me.CurrencyName.ShortName = value.CurrencyName_Account.ShortName Then Me.row_AmountDEV = Math.Abs(value.BallanceDEV) row_CurrencyName2 = Session.FindObject(Of CurrencyName)(CriteriaOperator.Parse("ShortName=?", value.CurrencyName_Account.ShortName)) Else row_CurrencyName2 = Session.FindObject(Of CurrencyName)(CriteriaOperator.Parse("ShortName=?", value.CurrencyName_Account.ShortName)) End If End If End If End If End Set End Property _ _ _ Property LiquidAssets_Main() As LiquidAssets Get Return _LiquidAssets End Get Set(ByVal value As LiquidAssets) SetPropertyValue("LiquidAssets_Main", _LiquidAssets, value) If Session.IsObjectsSaving = False And Session.IsObjectsLoading = False Then row_LiquidAssets = value If value IsNot Nothing Then CurrencyName = value.CurrencyName Me.row_CurrencyName2 = CurrencyName BallanceHUF = GetBallanceHUF(value, Now) BallanceDEV = GetBallanceDEV(value, Now) If Me.CustomersFrom IsNot Nothing Then If Me.DocumentNumber Is Nothing Then If value.NumberGeneratorIn IsNot Nothing Then Me.DocumentNumber = value.NumberGeneratorIn.GetNewNumber(value.NumberGeneratorIn) Me.Save() Session.CommitTransaction() End If End If End If End If End If End Set End Property _ _ _ Property row_AmountDEV2 As Double Get Return _row_AmountDEV2 End Get Set(value As Double) SetPropertyValue("row_AmountDEV2", _row_AmountDEV2, value) End Set End Property _ _ _ _ Property row_CurrencyRate2 As Double Get Return _row_CurrencyRate2 End Get Set(ByVal value As Double) SetPropertyValue("row_CurrencyRate2", _row_CurrencyRate2, value) If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then If row_CurrencyName2 Is Nothing Then row_CurrencyName2 = LiquidAssets_Main.CurrencyName If LiquidAssets_Main.CurrencyName.ShortName = "HUF" Then If LiquidAssets_Main.CurrencyName.ShortName = row_CurrencyName2.ShortName Then Else row_AmountDEV2 = row_AmountHUF * Math.Round(row_CurrencyRate2, 2, MidpointRounding.AwayFromZero) End If Else If LiquidAssets_Main.CurrencyName.ShortName = row_CurrencyName2.ShortName Then Else row_AmountDEV2 = row_AmountDEV * Math.Round(row_CurrencyRate2, 2, MidpointRounding.AwayFromZero) End If End If End If End Set End Property _ _ _ Property row_CurrencyName2 As Nuvolar.Module.CurrencyName Get Return _row_CurrencyName2 End Get Set(value As Nuvolar.Module.CurrencyName) SetPropertyValue("row_CurrencyName2", _row_CurrencyName2, value) End Set End Property Property TotalInAmountHUF As Double Get Return _TotalInAmountHUF End Get Set(ByVal value As Double) SetPropertyValue("TotalInAmountHUF", _TotalInAmountHUF, value) End Set End Property Property TotalOutAmountHUF As Double Get Return _TotalOutAmountHUF End Get Set(ByVal value As Double) SetPropertyValue("TotalOutAmountHUF", _TotalOutAmountHUF, value) End Set End Property Property TotalInAmountDEV As Double Get Return _TotalInAmountDEV End Get Set(ByVal value As Double) SetPropertyValue("TotalInAmountDEV", _TotalInAmountDEV, value) End Set End Property Property TotalOutAmountDEV As Double Get Return _TotalOutAmountDEV End Get Set(ByVal value As Double) SetPropertyValue("TotalOutAmountDEV", _TotalOutAmountDEV, value) End Set End Property Property BallanceHUF As Double Get Return _BallanceHUF End Get Set(ByVal value As Double) SetPropertyValue("BallanceHUF", _BallanceHUF, value) End Set End Property Property BallanceDEV As Double Get Return _BallanceDEV End Get Set(ByVal value As Double) SetPropertyValue("BallanceDEV", _BallanceDEV, value) End Set End Property Property GLHeader_RateDiff As GLHeader Get Return _GLHeader_RateDiff End Get Set(value As GLHeader) SetPropertyValue("GLHeader_RateDiff", _GLHeader_RateDiff, value) End Set End Property Sub RecalculateTotal() Dim _GLRows As GLRows TotalInAmountHUF = 0 TotalOutAmountHUF = 0 TotalInAmountDEV = 0 TotalOutAmountDEV = 0 For Each _GLRows In Me.GLRows TotalInAmountHUF += _GLRows.InAmountHUF TotalOutAmountHUF += _GLRows.OutAmountHUF TotalInAmountDEV += _GLRows.InAmountDEV TotalOutAmountDEV += _GLRows.OutAmountDEV Next BallanceHUF = TotalInAmountHUF - TotalOutAmountHUF BallanceDEV = TotalInAmountDEV - _TotalOutAmountDEV End Sub Function GetBallanceHUF(ByVal _LiquidAssets As LiquidAssets, ByVal _ToDate As Date) As Double Dim _GLCompensation_Collection As New XPCollection(Of GLCompensation)(Session, _ CriteriaOperator.Parse("LiquidAssets_Main=? and DateExecution<=? and IsEditable=False", _LiquidAssets, _ToDate)) Dim _GLCompensation As GLCompensation Dim _GLRows As GLRows Dim _InAmountHUF As Double = 0 Dim _OutAmountHUF As Double = 0 For Each _GLCompensation In _GLCompensation_Collection For Each _GLRows In _GLCompensation.GLRows _InAmountHUF += _GLRows.InAmountHUF _OutAmountHUF += _GLRows.OutAmountHUF Next Next Return _InAmountHUF - _OutAmountHUF End Function Function GetBallanceDEV(ByVal _LiquidAssets As LiquidAssets, ByVal _ToDate As Date) As Double Dim _GLCompensation_Collection As New XPCollection(Of GLCompensation)(Session, _ CriteriaOperator.Parse("LiquidAssets_Main=? and DateExecution<=? and IsEditable=False", _LiquidAssets, _ToDate)) Dim _GLBank As GLCompensation Dim _GLRows As GLRows Dim _InAmountDEV As Double = 0 Dim _OutAmountDEV As Double = 0 For Each _GLBank In _GLCompensation_Collection For Each _GLRows In _GLBank.GLRows _InAmountDEV += _GLRows.InAmountDEV _OutAmountDEV += _GLRows.OutAmountDEV Next Next Return _InAmountDEV - _OutAmountDEV End Function _ ReadOnly Property CloseHUF As Double Get Return Math.Round(TotalInAmountHUF, 2, MidpointRounding.AwayFromZero) - Math.Round(TotalOutAmountHUF, 2, MidpointRounding.AwayFromZero) End Get End Property _ ReadOnly Property CloseDEV As Double Get Return Math.Round(TotalInAmountDEV, 2, MidpointRounding.AwayFromZero) - Math.Round(TotalOutAmountDEV, 2, MidpointRounding.AwayFromZero) End Get End Property Overrides Property row_Controlling As Controlling Get Return MyBase.row_Controlling End Get Set(value As Controlling) MyBase.row_Controlling = value If Session.IsObjectsSaving = False And Session.IsObjectsLoading = False Then If value.ChartOfAccounts IsNot Nothing Then row_ChartOfAccounts = value.GetChartOfAccounts(Me.DateExecution.Year, False) End If End If End Set End Property End Class