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 ' A bekérõ, elõleg és végszámla iktatáshoz tartozó szabályok ' _ ' _ ' _ ' 0)", ViewType.DetailView)> ' _ ' _ ' _ ' _ ' _ ' _ ' _ ' _ ' 0", ViewType.DetailView)> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Public Class RegistryHeader '-- iktatórendszer Inherits BaseObject Private _CustomersFrom As CustomersFrom 'Saját cég Private _Customers As Customers 'Partner Private _Contacts As Contacts 'Partner kapcsolat, ha van kiválasztás akkor aut. partner Private _RegistryType As RegistryType 'Iktatás típusa Private _RegistryAcceptState As eRegistryAcceptState 'Elfogadva, vagy elutasítva Private _ShortName As String 'Megnevezés Private _DocumentNumber As String 'Bizonylatszám Private _RegistryNumber As String 'Iktatószám (a gép adja) Private _JobNumberObjects As JobNumberObjects 'Munkaszám Private _UniqueObjects As UniqueObjects 'Egyedi Private _DateCreated As Date = Now ' Dátum Private _DeliveryType As eDeliveryType 'Érkezés küldés módja Private _ReturnType As eDeliveryType ' Visszaküldés módja Private _DateReturn As Date 'Visszaküldés dátuma Private _RegistryRows As XPCollection(Of RegistryRows) 'Iktató sorok Private _DocumentFile As FileData Private _IsEditable As Boolean = True 'Szerkeszthetõ vagy végleges Private _IsStorno As Boolean = False Private _IsTemplate As Boolean = False Private _CurrentWorkflowSystemSteps As WorkflowSystemSteps 'Hanyadik lépésnél tart a dolog Private _HRResponsible As HRPerson 'Fõfelelõs Private _F_ConnectInfo As String 'Pontozási azonosító (mínuszos számlák miatt) Private _F_AdvanceAsk As RegistryHeader 'Ha elõlegszámla akkor a hozzá tartozó elõleg bekérõ megadása kötelezõ Private _F_FinalInvoice As RegistryHeader ' Ha elõlegszámla akkor melyik végszámlához tartozik Private _F_DateCreated As Date 'Számla kiállítási dátuma Private _F_DateExecution As Date 'Számla teljesítési dátuma Private _F_DateVAT As Date ' -- ÁFA dátuma Private _F_VATAvowalType As eVATAvowalType 'ÁFA bevallás módja Private _F_DatePayment As Date ' Számla fizetési határideje Private _F_AmountBruttoHUF As Double 'A számla végösszege bruttó HUF Private _F_AmountBruttoDEV As Double 'A számla végösszege bruttó DEV Private _F_CurrencyRate As Double = 1 'Árfolyam, ha nem HUF Private _F_CurrencyName As CurrencyName ' A számla devizaneme Private _F_CustomerBankAccounts As CustomerBankAccounts 'Partner bankszámlaszáma Private _F_IsImported As Boolean = False 'Fõkönyvbe be lett e már rögzítve Private _F_GLAccounts As GLAccounts 'A fõkönyvbe feladott szla Private _F_Paymode As ePayMode = ePayMode.NotSet Private _F_BookEntryErrorString As String = "" 'A szállítói számla, akkor a szállítói számla feladásakor feladási hibaüzenet. Private _F_ReadyforBookEntry As Boolean = False Private _BruttoAmountRemaining As Double 'ÁFÁ-ra bontás mennyi van még Private _BruttoAmountRemainingBank As Double = 0 'Utalásra bontásból mennyi van még Private _NettoAmountRemaining As Double 'Nettóra bontás mennyi van még Private _CauseOfRefuse As String ' -- Visszaküldés oka Private _CRM_Opportunities As CRM_Opportunities Private _UserCreated As User 'Létrehozta '// Nonpersistent propertyk annak érdekében, hogy ÁFA + Számlaigazolás gyorsabb legyen Private _row_VAT As VAT Private _row_VAT_BruttoAmount As Double '// Nonpersistent propertyk a gyors számlaigazolás elkészítéséhez Private _row_RRFC_Controlling As Controlling Private _row_RRFC_CostPlace As CostPlace Private _row_RRFC_CostHolder As CostHolder Private _row_RRFC_UniqueObjects As UniqueObjects Private _row_RRFC_JobNumberObjects As JobNumberObjects Private _row_RRFC_Note As String Private _row_RRFC_Amount As Double Private _row_RRFC_ContractRows As ContractRows Public Sub New(ByVal session As Session) MyBase.New(session) RegistryAcceptState = 0 End Sub Public Overrides Sub AfterConstruction() MyBase.AfterConstruction() Me.DeliveryType = eDeliveryType.ePostal Me.F_CurrencyName = Session.FindObject(Of CurrencyName)(1, CriteriaOperator.Parse("ShortName='HUF'")) End Sub Protected Overrides Sub OnSaving() MyBase.OnSaving() If Session.IsNewObject(Me) = True Then If RegistryNumber = "" And IsEditable = False Then DateCreated = GetSQLTime(Session) End If End If If Me.RegistryNumber = "" Then If Me.RegistryType IsNot Nothing Then Me.RegistryNumber = Me.RegistryType.NumberGenerator.GetNewNumber(Me.RegistryType.NumberGenerator, Year(Me.DateCreated).ToString, Month(Me.DateCreated).ToString) End If End If If Session.IsNewObject(Me) Then Dim _UserCreated As User = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser)) If _RegistryType IsNot Nothing Then If _RegistryType.AutomaticSetResponsible = True Then Dim _HRPerson As HRPerson = Session.FindObject(Of HRPerson)(CriteriaOperator.Parse("User=?", _UserCreated)) If _HRPerson IsNot Nothing Then Me.HRResponsible = _HRPerson End If End If End If Me.UserCreated = _UserCreated End If End Sub _ _ Property CustomersFrom() As CustomersFrom Get Return _CustomersFrom End Get Set(ByVal value As CustomersFrom) SetPropertyValue("CustomersFrom", _CustomersFrom, value) End Set End Property _ _ Property Customers As Customers Get Return _Customers End Get Set(ByVal value As Customers) SetPropertyValue("Customers", _Customers, value) If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving Then Me.F_CustomerBankAccounts = Nothing End If End Set End Property Property Contacts As Contacts Get Return _Contacts End Get Set(ByVal value As Contacts) SetPropertyValue("Contacts", _Contacts, value) 'If value Is Nothing Then 'Else ' Customers = value.Customers 'End If End Set End Property _ _ Property ShortName() As String Get Return _ShortName End Get Set(ByVal value As String) SetPropertyValue("ShortName", _ShortName, value) End Set End Property 4 and RegistryGLAccount=False")> Property RegistryType() As RegistryType Get Return _RegistryType End Get Set(ByVal value As RegistryType) SetPropertyValue("RegistryType", _RegistryType, value) If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then If Me.CurrentWorkflowSystemSteps Is Nothing Then If Me.RegistryType.WorkflowSystem Is Nothing Then Else CurrentWorkflowSystemSteps = Session.FindObject(Of WorkflowSystemSteps)(1, CriteriaOperator.Parse("StepIndex=1 and WorkflowSystem=?", Me.RegistryType.WorkflowSystem)) End If End If If Me.CustomersFrom IsNot Nothing And value IsNot Nothing Then If Me.IsEditable = True Then If Me.RegistryNumber = "" Or Me.RegistryNumber Is Nothing Then RegistryNumber = Me.RegistryType.NumberGenerator.GetNewNumber(Me.RegistryType.NumberGenerator, DateCreated.Date.Year.ToString, DateCreated.Date.Month.ToString) Me.Save() Session.CommitTransaction() End If End If End If End If End Set End Property Property RegistryAcceptState As eRegistryAcceptState Get Return _RegistryAcceptState End Get Set(ByVal value As eRegistryAcceptState) SetPropertyValue("RegistryAcceptState", _RegistryAcceptState, value) End Set End Property Property DocumentNumber() As String Get Return _DocumentNumber End Get Set(ByVal value As String) SetPropertyValue("DocumentNumber", _DocumentNumber, value) If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then If F_ConnectInfo <> value Then F_ConnectInfo = value End If End If End Set End Property Property RegistryNumber() As String Get Return _RegistryNumber End Get Set(ByVal value As String) SetPropertyValue("RegistryNumber", _RegistryNumber, value) End Set End Property Property JobNumberObjects() As JobNumberObjects Get Return _JobNumberObjects End Get Set(ByVal value As JobNumberObjects) SetPropertyValue("JobNumberObjects", _JobNumberObjects, value) End Set End Property Property UniqueObjects() As UniqueObjects Get Return _UniqueObjects End Get Set(ByVal value As UniqueObjects) SetPropertyValue("UniqueObjects", _UniqueObjects, value) End Set End Property Property DateCreated() As Date Get Return _DateCreated End Get Set(ByVal value As Date) SetPropertyValue("DateCreated", _DateCreated, value) End Set End Property Property DeliveryType() As eDeliveryType Get Return _DeliveryType End Get Set(ByVal value As eDeliveryType) SetPropertyValue("DeliveryType", _DeliveryType, value) End Set End Property Property ReturnType As eDeliveryType Get Return _ReturnType End Get Set(ByVal value As eDeliveryType) SetPropertyValue("ReturnType", _ReturnType, value) End Set End Property Property DateReturn As Date Get Return _DateReturn End Get Set(ByVal value As Date) SetPropertyValue("DateReturn", _DateReturn, value) End Set End Property Property DocumentFile() As FileData Get Return _DocumentFile End Get Set(ByVal value As FileData) SetPropertyValue("DocumentFile", _DocumentFile, value) End Set End Property Property IsEditable As Boolean Get Return _IsEditable End Get Set(ByVal value As Boolean) SetPropertyValue("IsEditable", _IsEditable, value) End Set End Property Property IsStorno As Boolean Get Return _IsStorno End Get Set(ByVal value As Boolean) SetPropertyValue("IsStorno", _IsStorno, value) End Set End Property Property IsTemplate As Boolean Get Return _IsTemplate End Get Set(value As Boolean) SetPropertyValue("IsTemplate", _IsTemplate, value) End Set End Property Property HRResponsible As HRPerson Get Return _HRResponsible End Get Set(ByVal value As HRPerson) SetPropertyValue("HRResponsible", _HRResponsible, value) End Set End Property Property UserCreated As User Get Return _UserCreated End Get Set(ByVal value As User) SetPropertyValue("UserCreated", _UserCreated, value) End Set End Property ' _ ' _ 'Property F_AdvanceAsk As RegistryHeader ' Get ' Return _F_AdvanceAsk ' End Get ' Set(ByVal value As RegistryHeader) ' SetPropertyValue("F_AdvanceAsk", _F_AdvanceAsk, value) ' End Set 'End Property 'Property F_FinalInvoice As RegistryHeader ' Get ' Return _F_FinalInvoice ' End Get ' Set(ByVal value As RegistryHeader) ' SetPropertyValue("F_FinalInvoice", _F_FinalInvoice, value) ' End Set 'End Property Property F_DateCreated As Date Get Return _F_DateCreated End Get Set(ByVal value As Date) SetPropertyValue("F_DateCreated", _F_DateCreated, value) End Set End Property Property F_DateExecution As Date Get Return _F_DateExecution End Get Set(ByVal value As Date) SetPropertyValue("F_DateExecution", _F_DateExecution, value) If Not Session.IsObjectsSaving And Not Session.IsObjectsLoading Then Me.F_DateVAT = value If F_PayMode = ePayMode.InContinuous Then F_DatePayment = value End If If F_CurrencyName IsNot Nothing Then If F_CurrencyName.ShortName <> "HUF" Then Dim _CurrencyRate_MNB_Collection = New XPCollection(Of CurrencyRate)(Session, CriteriaOperator.Parse("CurrencyName=? and IsMNB=True and GetDate(DateValid)<=?", F_CurrencyName, value.Date)) _CurrencyRate_MNB_Collection.Sorting.Add(New SortProperty("DateValid", DB.SortingDirection.Descending)) If _CurrencyRate_MNB_Collection.Count > 0 Then For Each _CurrencyRate_MNB In _CurrencyRate_MNB_Collection If _CurrencyRate_MNB.DateValid.Date = F_DateExecution.Date Then F_CurrencyRate = _CurrencyRate_MNB.RateAverage Exit For End If Exit For Next End If End If End If End If End Set End Property Property F_DateVAT As Date Get Return _F_DateVAT End Get Set(ByVal value As Date) SetPropertyValue("F_DateVAT", _F_DateVAT, value) If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving Then If Me.RegistryRowsFinancial.Count > 0 Then For Each _RegistryRowsFinancial As RegistryRowsFinancial In Me.RegistryRowsFinancial If Not _RegistryRowsFinancial.DateVAT = value Then _RegistryRowsFinancial.DateVAT = value End If Next End If End If End Set End Property Property F_VATAvowalType As eVATAvowalType Get Return _F_VATAvowalType End Get Set(value As eVATAvowalType) SetPropertyValue("F_VATAvowalType", _F_VATAvowalType, value) End Set End Property Property F_DatePayment As Date Get Return _F_DatePayment End Get Set(ByVal value As Date) SetPropertyValue("F_DatePayment", _F_DatePayment, value) End Set End Property Property F_AmountBruttoHUF As Double Get Return _F_AmountBruttoHUF End Get Set(ByVal value As Double) SetPropertyValue("F_AmountBruttoHUF", _F_AmountBruttoHUF, value) If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then If Me.RegistryType.RegistryMainType = eRegistryMainType.eAccount Then row_VAT = Session.FindObject(Of VAT)(CriteriaOperator.Parse("DefaultForBusinnes=True")) row_VAT_BruttoAmount = value End If End If End Set End Property Property F_AmountBruttoDEV As Double Get Return _F_AmountBruttoDEV End Get Set(ByVal value As Double) SetPropertyValue("F_AmountBruttoDEV", _F_AmountBruttoDEV, value) If Not Session.IsObjectsSaving And Not Session.IsObjectsLoading Then Me.F_AmountBruttoHUF = Math.Round((Me.F_AmountBruttoDEV * F_CurrencyRate), 0, MidpointRounding.AwayFromZero) End If End Set End Property Property F_CurrencyRate As Double Get Return _F_CurrencyRate End Get Set(ByVal value As Double) SetPropertyValue("F_CurrencyRate", _F_CurrencyRate, value) If Not Session.IsObjectsSaving And Not Session.IsObjectsLoading Then Me.F_AmountBruttoHUF = Math.Round((Me.F_AmountBruttoDEV * F_CurrencyRate), 0, MidpointRounding.AwayFromZero) End If End Set End Property Property F_CurrencyName As CurrencyName Get Return _F_CurrencyName End Get Set(ByVal value As CurrencyName) SetPropertyValue("F_CurrencyName", _F_CurrencyName, value) If Session.IsObjectsSaving = False And Session.IsObjectsLoading = False Then If F_CurrencyName IsNot Nothing Then If F_CurrencyName.ShortName <> "HUF" Then Dim _CurrencyRate_MNB_Collection = New XPCollection(Of CurrencyRate)(Session, CriteriaOperator.Parse("CurrencyName=? and IsMNB=True and GetDate(DateValid)<=?", F_CurrencyName, F_DateExecution.Date)) _CurrencyRate_MNB_Collection.Sorting.Add(New SortProperty("DateValid", DB.SortingDirection.Descending)) If _CurrencyRate_MNB_Collection.Count > 0 Then For Each _CurrencyRate_MNB In _CurrencyRate_MNB_Collection If _CurrencyRate_MNB.DateValid.Date = F_DateExecution.Date Then F_CurrencyRate = _CurrencyRate_MNB.RateAverage Exit For End If Exit For Next End If End If End If End If End Set End Property Property F_CustomerBankAccounts As CustomerBankAccounts Get Return _F_CustomerBankAccounts End Get Set(ByVal value As CustomerBankAccounts) SetPropertyValue("F_CustomerBankAccounts", _F_CustomerBankAccounts, value) End Set End Property Property F_PayMode As ePayMode Get Return _F_Paymode End Get Set(ByVal value As ePayMode) SetPropertyValue("F_PayMode", _F_Paymode, value) If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving Then If value = ePayMode.InContinuous Then F_DatePayment = _F_DateExecution End If If value = ePayMode.InCash Then F_DateExecution = F_DateCreated F_DatePayment = F_DateCreated End If End If End Set End Property Property CurrentWorkflowSystemSteps As WorkflowSystemSteps Get Return _CurrentWorkflowSystemSteps End Get Set(ByVal value As WorkflowSystemSteps) SetPropertyValue("CurrentWorkflowSystemSteps", _CurrentWorkflowSystemSteps, value) End Set End Property Property F_IsImported As Boolean Get Return _F_IsImported End Get Set(ByVal value As Boolean) SetPropertyValue("F_IsImported", _F_IsImported, value) End Set End Property Property F_GLAccounts As GLAccounts Get Return _F_GLAccounts End Get Set(ByVal value As GLAccounts) SetPropertyValue("F_GLAccounts", _F_GLAccounts, value) End Set End Property Property F_BookEntryErrorString As String Get Return _F_BookEntryErrorString End Get Set(ByVal value As String) SetPropertyValue("F_BookEntryErrorString", _F_BookEntryErrorString, value) End Set End Property Property F_ReadyforBookEntry As Boolean Get Return _F_ReadyforBookEntry End Get Set(ByVal value As Boolean) SetPropertyValue("F_ReadyforBookEntry", _F_ReadyforBookEntry, value) End Set End Property Property F_ConnectInfo As String Get Return _F_ConnectInfo End Get Set(value As String) SetPropertyValue("F_ConnectInfo", _F_ConnectInfo, value) End Set End Property ReadOnly Property F_IsBookEntry As Boolean Get If _F_GLAccounts IsNot Nothing Then Return True Else Return False End If End Get End Property Property BruttoAmountRemaining As Double Get Dim _RowsAmount As Double = 0 Dim _RegistryRowsFinancial As RegistryRowsFinancial For Each _RegistryRowsFinancial In Me.RegistryRowsFinancial If Session.IsNewObject(_RegistryRowsFinancial) = False Then _RowsAmount += _RegistryRowsFinancial.BruttoAmount End If Next _BruttoAmountRemaining = F_AmountBruttoHUF - _RowsAmount Return Math.Round(_BruttoAmountRemaining, 2, MidpointRounding.AwayFromZero) End Get Set(ByVal value As Double) SetPropertyValue("BruttoAmountRemainig", _BruttoAmountRemaining, value) End Set End Property Property NettoAmountRemaining As Double Get Dim _RowsAmount As Double = 0 Dim _VATAmount As Double = 0 Dim _RegistryRowsFinancialControlling As RegistryRowsFinancialControlling Dim _RegistryRowsFinancial As RegistryRowsFinancial For Each _RegistryRowsFinancial In Me.RegistryRowsFinancial If _RegistryRowsFinancial.VAT IsNot Nothing Then _VATAmount += _RegistryRowsFinancial.BruttoAmount / (100 + _RegistryRowsFinancial.VAT.KeyValuePercent) * _RegistryRowsFinancial.VAT.KeyValuePercent Else End If Next _VATAmount = Math.Round(_VATAmount, 0, MidpointRounding.AwayFromZero) For Each _RegistryRowsFinancialControlling In Me.RegistryRowsFinancialControlling If Session.IsNewObject(_RegistryRowsFinancialControlling) = False Then _RowsAmount += _RegistryRowsFinancialControlling.Amount End If Next _NettoAmountRemaining = F_AmountBruttoHUF - _VATAmount - _RowsAmount 'Me.row_RRFC_Amount = _NettoAmountRemaining Return Math.Round(_NettoAmountRemaining, 2, MidpointRounding.AwayFromZero) End Get Set(ByVal value As Double) SetPropertyValue("NettoAmountRemainig", _NettoAmountRemaining, value) If Session.IsObjectsSaving = False And Session.IsObjectsLoading = False Then If RegistryType IsNot Nothing Then If RegistryType.RegistryMainType = eRegistryMainType.eAccount Then If Me.row_RRFC_ContractRows Is Nothing Then 'Me.row_RRFC_Amount = value End If End If End If value = Math.Round(value, 2, MidpointRounding.AwayFromZero) End If End Set End Property Property BruttoAmountRemainingBank As Double Get If Me._F_Paymode = ePayMode.InTransfer Then Dim _RowsAmountHUF As Double = 0 Dim _RegistryBankTransfer As RegistryBankTransfer For Each _RegistryBankTransfer In Me.RegistryBankTransfer _RowsAmountHUF += _RegistryBankTransfer.AmountHUF Next _BruttoAmountRemainingBank = F_AmountBruttoHUF - _RowsAmountHUF Return _BruttoAmountRemainingBank Else Return 0 End If End Get Set(ByVal value As Double) SetPropertyValue("BruttoAmountRemainigBank", _BruttoAmountRemainingBank, value) End Set End Property Property CauseOfRefuse As String Get Return _CauseOfRefuse End Get Set(ByVal value As String) SetPropertyValue("CauseOfRefuse", _CauseOfRefuse, value) End Set End Property ' _ Property CRM_Opportunities As CRM_Opportunities Get Return _CRM_Opportunities End Get Set(ByVal value As CRM_Opportunities) SetPropertyValue("CRM_Opportunities", _CRM_Opportunities, value) End Set End Property ReadOnly Property HasTransferedBank As Boolean ' -- van e a számlának utalási csomagba tett tétele? mert akkor nem szabad módosítani a számla összegét! Get Dim _HasTransferedBank As Boolean = False If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving Then If Me.RegistryBankTransfer.Count > 0 Then For Each _RegistryBankTransfer As RegistryBankTransfer In Me.RegistryBankTransfer If Not _RegistryBankTransfer.BankSavedFileName = "" Then _HasTransferedBank = True End If Next End If End If Return _HasTransferedBank End Get End Property ReadOnly Property DisplayName As String Get If RegistryType IsNot Nothing And RegistryNumber IsNot Nothing And Customers IsNot Nothing Then Return RegistryType.ShortName & ", " & RegistryNumber & ", " & Customers.FullName Else Return "" End If End Get End Property '// Nonpersistent propertyk VAT igazoláshoz Property row_VAT As VAT Get Return _row_VAT End Get Set(value As VAT) SetPropertyValue("row_VAT", _row_VAT, value) End Set End Property Property row_VAT_BruttoAmount As Double Get Return _row_VAT_BruttoAmount End Get Set(value As Double) SetPropertyValue("row_VAT_BruttoAmount", _row_VAT_BruttoAmount, value) End Set End Property '// Nonpersistent propertyk RRFC igazoláshoz Property row_RRFC_Controlling As Controlling Get Return _row_RRFC_Controlling End Get Set(value As Controlling) SetPropertyValue("row_RRFC_Controlling", _row_RRFC_Controlling, value) End Set End Property Property row_RRFC_CostPlace As CostPlace Get Return _row_RRFC_CostPlace End Get Set(value As CostPlace) SetPropertyValue("row_RRFC_CostPlace", _row_RRFC_CostPlace, value) End Set End Property Property row_RRFC_CostHolder As CostHolder Get Return _row_RRFC_CostHolder End Get Set(value As CostHolder) SetPropertyValue("row_RRFC_CostHolder", _row_RRFC_CostHolder, value) End Set End Property Property row_RRFC_JobNumberObjects As JobNumberObjects Get Return _row_RRFC_JobNumberObjects End Get Set(value As JobNumberObjects) SetPropertyValue("row_RRFC_JobNumberObjects", _row_RRFC_JobNumberObjects, value) End Set End Property Property row_RRFC_UniqueObjects As UniqueObjects Get Return _row_RRFC_UniqueObjects End Get Set(value As UniqueObjects) SetPropertyValue("row_RRFC_UniqueObjects", _row_RRFC_UniqueObjects, value) End Set End Property Property row_RRFC_Note As String Get Return _row_RRFC_Note End Get Set(value As String) SetPropertyValue("row_RRFC_Note", _row_RRFC_Note, value) End Set End Property Property row_RRFC_Amount As Double Get Return _row_RRFC_Amount End Get Set(value As Double) SetPropertyValue("row_RRFC_Amount", _row_RRFC_Amount, value) End Set End Property Property row_RRFC_ContractRows As ContractRows Get Return _row_RRFC_ContractRows End Get Set(value As ContractRows) SetPropertyValue("row_RRFC_ContractRows", _row_RRFC_ContractRows, value) If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then If value IsNot Nothing Then row_RRFC_Controlling = value.Controlling row_RRFC_UniqueObjects = value.UniqueObjects row_RRFC_Note = value.Description row_RRFC_CostHolder = value.CostHolder row_RRFC_CostPlace = value.CostPlace row_RRFC_JobNumberObjects = value.JobNumberObjects If Me.F_CurrencyName.ShortName <> "HUF" Then row_RRFC_Amount = Math.Round(value.NettoPriceDEV * Me.F_CurrencyRate, 0, MidpointRounding.AwayFromZero) Else Me.row_RRFC_Amount = value.NettoPriceHUF End If End If End If End Set End Property _ ReadOnly Property IsVATClosed As Boolean Get Dim _Closed As Boolean = False If Me.CustomersFrom IsNot Nothing Then If Me.RegistryType IsNot Nothing Then Select Case Me.RegistryType.RegistryMainType Case eRegistryMainType.eAccount, eRegistryMainType.eInvoiceAdvance, eRegistryMainType.eInvoiceFinal Dim _VATReport As VATReport = Session.FindObject(Of VATReport) _ (CriteriaOperator.Parse("GetDate(DateFrom)<=? and GetDate(DateTo)>=? and CustomersFrom=? and Closed=True", _ Me.F_DateVAT.Date, Me.F_DateVAT.Date, Me.CustomersFrom)) If _VATReport IsNot Nothing Then _Closed = _VATReport.Closed End If End Select End If End If Return _Closed End Get End Property '-- XPCollections ------------------- _ ReadOnly Property RegistryRows() As XPCollection(Of RegistryRows) Get Return GetCollection(Of RegistryRows)("RegistryRows") End Get End Property _ ReadOnly Property RegistryRowsFinancial() As XPCollection(Of RegistryRowsFinancial) Get Return GetCollection(Of RegistryRowsFinancial)("RegistryRowsFinancial") End Get End Property _ ReadOnly Property RegistryRowsFinancialControlling() As XPCollection(Of RegistryRowsFinancialControlling) Get Return GetCollection(Of RegistryRowsFinancialControlling)("RegistryRowsFinancialControlling") End Get End Property _ ReadOnly Property RegistryTasks As XPCollection(Of RegistryTasks) Get Return New XPCollection(Of RegistryTasks)(Session, CriteriaOperator.Parse("RegistryHeader=?", Me)) End Get End Property _ ReadOnly Property RegistryFileData As XPCollection(Of RegistryFileData) Get Return GetCollection(Of RegistryFileData)("RegistryFileData") End Get End Property _ ReadOnly Property PCIDetail As XPCollection(Of PCIDetail) Get If Session.IsNewObject(Me) = False Then If Me.RegistryType.RegistryMainType = eRegistryMainType.eAccount Then Return New XPCollection(Of PCIDetail)(Session, _ CriteriaOperator.Parse("CustomersFrom=? and Customers=? and PartnerType=1 and ConnectInfo=?", _ Me.CustomersFrom, Me.Customers, Me.DocumentNumber)) Else Return Nothing End If Else Return Nothing End If End Get End Property _ ReadOnly Property WorkFlowCollection As XPCollection(Of WorkflowSystemSteps) Get If Me.RegistryType Is Nothing Then Return Nothing End If If Me.RegistryType.WorkflowSystem Is Nothing Then Return Nothing End If Dim _WorkFlowSystemSteps_Collection As New XPCollection(Of WorkflowSystemSteps)(Session, CriteriaOperator.Parse("WorkflowSystem=?", Me.RegistryType.WorkflowSystem)) Return _WorkFlowSystemSteps_Collection End Get End Property _ ReadOnly Property RegistryBankTransfer As XPCollection(Of RegistryBankTransfer) Get Return GetCollection(Of RegistryBankTransfer)("RegistryBankTransfer") End Get End Property _ ReadOnly Property ChartOfAccountsYearIsClosed As Boolean Get If Me.RegistryType.RegistryMainType = eRegistryMainType.eAccount Then Dim _ChartOfAccountsYear As ChartOfAccountsYear = Session.FindObject(Of ChartOfAccountsYear)(CriteriaOperator.Parse("AccountYear=?", Me.F_DateExecution.Year)) If _ChartOfAccountsYear Is Nothing Then Return True Else Return _ChartOfAccountsYear.IsClosed End If Else Return False End If End Get End Property '--Metódusok ----------------------------------- ' _ ' _ 'Public Function ESR_F_CurrencyRate( ByRef active As Boolean) As EditorState ' active = _F_CurrencyName.ShortName = "HUF" ' Return EditorState.Hidden 'End Function ' _ ' _ 'Public Function ESR_F_RegistryBankTransfer( ByRef active As Boolean) As EditorState ' If Me.RegistryType IsNot Nothing Then ' active = Not ((F_PayMode = ePayMode.InTransfer Or F_PayMode = ePayMode.InContinuous) And Me.RegistryType.RegistryMainType = eRegistryMainType.eAccount) ' Return EditorState.Hidden ' End If 'End Function Sub BookEntryRemove(ByVal _p_RegistryHeader As RegistryHeader, ByVal _uow As UnitOfWork, Optional ByVal _WithCommit As Boolean = False, Optional _KeepReady As Boolean = False) 'Az eljárás visszavon egy feladást a fõkönyvbõl Dim _RegistryRowsFinancial As RegistryRowsFinancial Dim _RegistryRowsFinancialControlling As RegistryRowsFinancialControlling Dim _RegistryHeader As RegistryHeader = _uow.GetObjectByKey(Of RegistryHeader)(_p_RegistryHeader.Oid) Dim _ChartOfAccountsYear As ChartOfAccountsYear = _uow.FindObject(Of ChartOfAccountsYear)(CriteriaOperator.Parse("AccountYear=?", _RegistryHeader.F_DateExecution.Year)) If _ChartOfAccountsYear.IsClosed Then _RegistryHeader.F_BookEntryErrorString = String.Format("Zárolt főkönyvi év ! {0}", _RegistryHeader.F_DateExecution.Year.ToString) _RegistryHeader.Save() If _WithCommit Then _uow.CommitTransaction() Exit Sub End If Dim _GLRows_Collection As New XPCollection(Of GLRows)(_uow, CriteriaOperator.Parse("GLHeader.Oid=?", _RegistryHeader.F_GLAccounts.Oid)) _uow.Delete(_GLRows_Collection) Dim _GLAccounts_Collection As New XPCollection(Of GLAccounts)(_uow, CriteriaOperator.Parse("Oid=?", _RegistryHeader.F_GLAccounts.Oid)) _uow.Delete(_GLAccounts_Collection) _RegistryHeader.F_GLAccounts = Nothing _RegistryHeader.F_ReadyforBookEntry = False For Each _RegistryRowsFinancial In _RegistryHeader.RegistryRowsFinancial If _KeepReady = False Then _RegistryRowsFinancial.F_ReadyforBookEntryRows = False Next For Each _RegistryRowsFinancialControlling In _RegistryHeader.RegistryRowsFinancialControlling If _KeepReady = False Then _RegistryRowsFinancialControlling.F_ReadyforBookEntryRows = False Next If _WithCommit Then _uow.CommitChanges() End Sub Sub BookEntry(ByVal _p_BookEntryMode As Long, ByVal _p_RegistryHeader As RegistryHeader, ByVal _uow As UnitOfWork, Optional ByVal _WithCommit As Boolean = False) ' Az eljárás feladást készít errõl a számláról ' BookentryMode=0 akkor tételes fealás ' BookentryMode=1 akkor jelölõadatokra csoportosított feladás If _p_RegistryHeader Is Nothing Then Exit Sub Dim _RegistryHeader As RegistryHeader = _uow.GetObjectByKey(Of RegistryHeader)(_p_RegistryHeader.Oid) Dim _RegistryRowsFinancialControlling As RegistryRowsFinancialControlling Dim _RegistryRowsFinancial As RegistryRowsFinancial Dim _GLAccounts As GLAccounts Dim _GLRows As GLRows Dim _CreditChartOfAccounts As ChartOfAccounts Dim _GUID As Guid = Guid.NewGuid Dim _DebitChartOfAccounts As ChartOfAccounts Dim _AmountDEV As Double = 0 ' Megnézi, hogy történt-e már feladás If _RegistryHeader.F_GLAccounts IsNot Nothing Then BookEntryRemove(_RegistryHeader, _uow, False) End If If BookEntryCheck(_p_BookEntryMode, _RegistryHeader, _uow, _WithCommit) = False Then Exit Sub End If If _p_BookEntryMode = 0 Then 'Tételes feladás a fõkönyvbe _GLAccounts = New GLAccounts(_uow) _GLAccounts.AmountDEVBrutto = _RegistryHeader.F_AmountBruttoDEV _GLAccounts.AmountHUFBrutto = _RegistryHeader.F_AmountBruttoHUF _GLAccounts.ImportedRegistryHeader = _RegistryHeader _GLAccounts.Customers = _RegistryHeader.Customers If _RegistryHeader.RegistryType.RegistryDirection = eRegistryDirection.eOutput Then _GLAccounts.PartnerType = ePartnerType.eReceivables _DebitChartOfAccounts = _RegistryHeader.Customers.CustomersGLParameters.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, eVATMode.eOut) Else _GLAccounts.PartnerType = ePartnerType.ePayabels _CreditChartOfAccounts = _RegistryHeader.Customers.CustomersGLParameters.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, eVATMode.eIn) End If _GLAccounts.CurrencyName = _RegistryHeader.F_CurrencyName _GLAccounts.CurrencyRate = _RegistryHeader.F_CurrencyRate _GLAccounts.CustomersFrom = _RegistryHeader.CustomersFrom _GLAccounts.DateCreated = _RegistryHeader.F_DateCreated.Date _GLAccounts.DateExecution = _RegistryHeader.F_DateExecution.Date _GLAccounts.PaymentOption = _uow.FindObject(Of PaymentOption)(CriteriaOperator.Parse("PayMode=?", _RegistryHeader.F_PayMode), True) _GLAccounts.DatePayment = _RegistryHeader.F_DatePayment.Date _GLAccounts.DocumentFile = _RegistryHeader.DocumentFile _GLAccounts.DocumentNumber = _RegistryHeader.DocumentNumber _GLAccounts.ConnectInfo = _RegistryHeader.F_ConnectInfo _GLAccounts.IsEditable = False _GLAccounts.IsStorno = False _GLAccounts.NoteHeader = _RegistryHeader.ShortName _GLAccounts.RegistryNumber = _RegistryHeader.RegistryNumber _GLAccounts.Save() _RegistryHeader.F_GLAccounts = _GLAccounts _RegistryHeader.Save() '--- Nettó sorok For Each _RegistryRowsFinancialControlling In _RegistryHeader.RegistryRowsFinancialControlling '-- Netto sor _GLRows = New GLRows(_uow) _GLRows.ConnectInfoAdvanced = _RegistryRowsFinancialControlling.ConnectInfoAdvanced If _RegistryRowsFinancialControlling.DateExecution = Nothing Then _GLRows.DateExecution = _RegistryRowsFinancialControlling.RegistryHeader.F_DateExecution Else _GLRows.DateExecution = _RegistryRowsFinancialControlling.DateExecution End If _GLRows.RegistryRowsFinancialControlling = _RegistryRowsFinancialControlling If _RegistryRowsFinancialControlling.ChartOfAccounts Is Nothing Then '// Ha szállítói számláról van szó If _RegistryHeader.RegistryType.RegistryDirection = eRegistryDirection.eOutput Then _CreditChartOfAccounts = _RegistryRowsFinancialControlling.Controlling.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, False) Else If _RegistryRowsFinancialControlling.IsReInvoice = True Then _DebitChartOfAccounts = _RegistryRowsFinancialControlling.Controlling.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, True) Else _DebitChartOfAccounts = _RegistryRowsFinancialControlling.Controlling.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, False) End If End If Else _DebitChartOfAccounts = _RegistryRowsFinancialControlling.ChartOfAccounts End If If _RegistryRowsFinancialControlling.RegistryHeader.F_CurrencyName.ShortName = "HUF" Then _GLRows.AddGLRows(TryCast(_GLAccounts, GLHeader), _DebitChartOfAccounts, _CreditChartOfAccounts, 0, _ _RegistryRowsFinancialControlling.Amount, Nothing, _RegistryHeader.Customers, _RegistryHeader.F_DateVAT, Nothing, _ _RegistryRowsFinancialControlling.Note, _RegistryRowsFinancialControlling.UniqueObjects, _RegistryRowsFinancialControlling.Controlling, _RegistryRowsFinancialControlling.JobNumberObjects, _ _RegistryRowsFinancialControlling.CostPlace, _RegistryRowsFinancialControlling.CostHolder, _RegistryHeader.F_ConnectInfo, eGLRowsTypeVAT.eNettoRow, _ _GUID, eTransactionType.eNotSet, eCashType.ePartner, ePartnerType.ePayabels) Else If _RegistryRowsFinancialControlling.RegistryHeader.F_CurrencyRate <> 0 Then _GLRows.AddGLRows(TryCast(_GLAccounts, GLHeader), _DebitChartOfAccounts, _CreditChartOfAccounts, _RegistryRowsFinancialControlling.Amount / _RegistryRowsFinancialControlling.RegistryHeader.F_CurrencyRate, _ _RegistryRowsFinancialControlling.Amount, Nothing, _RegistryHeader.Customers, _RegistryHeader.F_DateVAT, Nothing, _ _RegistryRowsFinancialControlling.Note, _RegistryRowsFinancialControlling.UniqueObjects, _RegistryRowsFinancialControlling.Controlling, _RegistryRowsFinancialControlling.JobNumberObjects, _ _RegistryRowsFinancialControlling.CostPlace, _RegistryRowsFinancialControlling.CostHolder, _RegistryHeader.F_ConnectInfo, eGLRowsTypeVAT.eNettoRow, _ _GUID, eTransactionType.eNotSet, eCashType.ePartner, ePartnerType.ePayabels) Else _GLRows.AddGLRows(TryCast(_GLAccounts, GLHeader), _DebitChartOfAccounts, _CreditChartOfAccounts, 0, _ _RegistryRowsFinancialControlling.Amount, Nothing, _RegistryHeader.Customers, _RegistryHeader.F_DateVAT, Nothing, _ _RegistryRowsFinancialControlling.Note, _RegistryRowsFinancialControlling.UniqueObjects, _RegistryRowsFinancialControlling.Controlling, _RegistryRowsFinancialControlling.JobNumberObjects, _ _RegistryRowsFinancialControlling.CostPlace, _RegistryRowsFinancialControlling.CostHolder, _RegistryHeader.F_ConnectInfo, eGLRowsTypeVAT.eNettoRow, _ _GUID, eTransactionType.eNotSet, eCashType.ePartner, ePartnerType.ePayabels) End If End If Next '-- ÁFA sorok ------------------------------------- For Each _RegistryRowsFinancial In _RegistryHeader.RegistryRowsFinancial '-- ÁFA sor Dim _VATAmountDEV As Double = 0 If _RegistryRowsFinancial.RegistryHeader.F_CurrencyRate <> 0 Then If _RegistryRowsFinancial.RegistryHeader.F_CurrencyName.ShortName <> "HUF" Then _VATAmountDEV = Math.Round(_RegistryRowsFinancial.VATAmount / _RegistryRowsFinancial.RegistryHeader.F_CurrencyRate, 2, MidpointRounding.AwayFromZero) End If End If If _RegistryRowsFinancial.VAT.InversState = True Then _GLRows = New GLRows(_uow) _GLRows.AddGLRows(TryCast(_GLAccounts, GLHeader), _RegistryRowsFinancial.VAT.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, eVATMode.eIn), _ _RegistryRowsFinancial.VAT.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, eVATMode.eOut), 0, _ Math.Round(_RegistryRowsFinancial.NettoAmount * _RegistryRowsFinancial.VAT.InversKeyValue, 0, MidpointRounding.AwayFromZero), _ Nothing, _RegistryHeader.Customers, _RegistryRowsFinancial.DateVAT, _RegistryRowsFinancial.VAT, _ _RegistryRowsFinancial.Note, Nothing, Nothing, Nothing, _ Nothing, Nothing, _RegistryHeader.F_ConnectInfo, eGLRowsTypeVAT.eVATRow, _ _GUID, eTransactionType.eNotSet, eCashType.ePartner, ePartnerType.ePayabels) _GLRows = New GLRows(_uow) Else _GLRows = New GLRows(_uow) If _RegistryHeader.RegistryType.RegistryDirection = eRegistryDirection.eOutput Then _DebitChartOfAccounts = _RegistryHeader.Customers.CustomersGLParameters.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, eVATMode.eOut) _CreditChartOfAccounts = _RegistryRowsFinancial.VAT.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, eVATMode.eOut) Else _DebitChartOfAccounts = _RegistryRowsFinancial.VAT.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, eVATMode.eIn) _CreditChartOfAccounts = _RegistryHeader.Customers.CustomersGLParameters.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, eVATMode.eIn) End If _GLRows.AddGLRows(TryCast(_GLAccounts, GLHeader), _DebitChartOfAccounts, _CreditChartOfAccounts, _VATAmountDEV, _ _RegistryRowsFinancial.VATAmount, Nothing, _RegistryHeader.Customers, _RegistryRowsFinancial.DateVAT, _RegistryRowsFinancial.VAT, _ _RegistryRowsFinancial.Note, Nothing, Nothing, Nothing, _ Nothing, Nothing, _RegistryHeader.F_ConnectInfo, eGLRowsTypeVAT.eVATRow, _ _GUID, eTransactionType.eNotSet, eCashType.ePartner, ePartnerType.ePayabels) End If Next ElseIf _p_BookEntryMode = 1 Then '-- Összevont feladás End If If _WithCommit Then _uow.CommitChanges() End Sub Function BookEntryCheck(ByVal _BookEntryMode As Long, ByVal _RegistryHeader As RegistryHeader, ByVal _uow As UnitOfWork, Optional ByVal WithCommit As Boolean = False) 'Feladás elõtti ellenõrzés 'Mit kell ellenõrizni ? 'Fõkönyvi számlák, Debit,Credit 'ÁFA fõkönyvi számlája 'CM számok Dim _ChartOfAccountsYear As ChartOfAccountsYear = _uow.FindObject(Of ChartOfAccountsYear)(CriteriaOperator.Parse("AccountYear=?", _RegistryHeader.F_DateExecution.Year)) If _ChartOfAccountsYear.IsClosed Then _RegistryHeader.F_BookEntryErrorString = String.Format("Zárolt főkönyvi év ! {0}", _RegistryHeader.F_DateExecution.Year.ToString) _RegistryHeader.Save() _uow.CommitTransaction() Return False End If Dim _RegistryRowsFinancialControlling As RegistryRowsFinancialControlling Dim _Exists As Boolean = False Dim _RegistryTask As RegistryTasks Dim _RegistryTask_Collection As New XPCollection(Of RegistryTasks)(_uow, CriteriaOperator.Parse("RegistryHeader=? and Status<>4", _RegistryHeader)) If _RegistryHeader.F_GLAccounts IsNot Nothing Then _RegistryHeader._F_BookEntryErrorString = String.Format("Könyvelve") _RegistryHeader.Save() _uow.CommitTransaction() Return False End If For Each _RegistryRowsFinancialControlling In _RegistryHeader.RegistryRowsFinancialControlling _Exists = True If _RegistryRowsFinancialControlling.Controlling Is Nothing Then 'Nincs meadva a kontrollszám _RegistryHeader._F_BookEntryErrorString = String.Format("Nincs kontrollszám {0}", _RegistryRowsFinancialControlling.Note) _RegistryHeader.Save() _uow.CommitTransaction() Return False Else If _RegistryRowsFinancialControlling.Controlling.GetChartOfAccounts(_RegistryHeader.F_DateExecution.Year, _RegistryRowsFinancialControlling.IsReInvoice) Is Nothing Then 'Nincs megadva a kontrollszámhoz tartozó FK számla száma _RegistryHeader._F_BookEntryErrorString = String.Format("Nincs fk. számla száma {0}", _RegistryRowsFinancialControlling.Controlling.Name) _RegistryHeader.Save() _uow.CommitTransaction() Return False End If If _RegistryRowsFinancialControlling.F_ReadyforBookEntryRows = False Then _RegistryHeader._F_BookEntryErrorString = String.Format("Nem könyvelhetõ minden nettó sora !") _RegistryHeader.Save() _uow.CommitTransaction() Return False End If End If Next If _Exists = False Then _RegistryHeader._F_BookEntryErrorString = String.Format("Nincs teljesítési igazolási sor !") _RegistryHeader.Save() _uow.CommitTransaction() Return False End If Dim _RegistryRowsFinancial As RegistryRowsFinancial For Each _RegistryRowsFinancial In _RegistryHeader.RegistryRowsFinancial If _RegistryRowsFinancial.F_ReadyforBookEntryRows = False Then _RegistryHeader._F_BookEntryErrorString = String.Format("Nem könyvelhető minden ÁFA sora !") _RegistryHeader.Save() _uow.CommitTransaction() Return False End If Next '-- Meg kell nézni, hogy ez az iktatás olyan Task-hoz tartozik e, amely workflowsystemstep IsReadyForImport = True For Each _RegistryTask In _RegistryTask_Collection If _RegistryTask.CurrentWorkflowSystemSteps.IsReadyForImport = False Then _RegistryHeader._F_BookEntryErrorString = String.Format("Nem a lekönyvelhető lépésen van a feladat !") _RegistryHeader.Save() _uow.CommitTransaction() Return False End If Next Return True End Function Sub RecalculateVAT(_ocur As Xpo.XPObjectSpace, _RegistryHeader As RegistryHeader) Dim _NettoAmount_RRF As Double = 0 Dim _NettoAmount_RRFC As Double = 0 Dim _NettoDiff As Double = 0 Dim _RegistryRowsFinancial As RegistryRowsFinancial Dim _RegistryRowsFinancialControlling As RegistryRowsFinancialControlling For Each _RegistryRowsFinancial In _RegistryHeader.RegistryRowsFinancial _NettoAmount_RRF += _RegistryRowsFinancial.NettoAmount Next For Each _RegistryRowsFinancialControlling In _RegistryHeader.RegistryRowsFinancialControlling _NettoAmount_RRFC += _RegistryRowsFinancialControlling.Amount Next _NettoDiff = _NettoAmount_RRF - _NettoAmount_RRFC If _NettoDiff <> 0 Then For Each _RegistryRowsFinancialControlling In _RegistryHeader.RegistryRowsFinancialControlling _RegistryRowsFinancialControlling.Amount = Math.Round(_RegistryRowsFinancialControlling.Amount * (_NettoAmount_RRF / _NettoAmount_RRFC), 0, MidpointRounding.AwayFromZero) If _RegistryRowsFinancialControlling.ContractRows IsNot Nothing Then If _RegistryRowsFinancialControlling.ContractRows.CurrencyName.ShortName = "HUF" Then _RegistryRowsFinancialControlling.ContractRows.NettoPriceHUF = _RegistryRowsFinancialControlling.Amount Else _RegistryRowsFinancialControlling.ContractRows.NettoPriceHUF = _RegistryRowsFinancialControlling.Amount _RegistryRowsFinancialControlling.ContractRows.NettoPriceDEV = _RegistryRowsFinancialControlling.ContractRows.NettoPriceHUF * _RegistryHeader.F_CurrencyRate End If End If Next _NettoAmount_RRF = 0 _NettoAmount_RRFC = 0 For Each _RegistryRowsFinancial In _RegistryHeader.RegistryRowsFinancial _NettoAmount_RRF += _RegistryRowsFinancial.NettoAmount Next For Each _RegistryRowsFinancialControlling In _RegistryHeader.RegistryRowsFinancialControlling _NettoAmount_RRFC += _RegistryRowsFinancialControlling.Amount Next _NettoDiff = _NettoAmount_RRF - _NettoAmount_RRFC If _NettoDiff <> 0 Then Dim _RegistryRowsFinancialControlling_Collection As XPCollection = _ocur.CreateCollection(GetType(RegistryRowsFinancialControlling), CriteriaOperator.Parse("RegistryHeader=?", _RegistryHeader)) _RegistryRowsFinancialControlling_Collection.Sorting.Add(New SortProperty("Amount", DB.SortingDirection.Descending)) TryCast(_RegistryRowsFinancialControlling_Collection(0), RegistryRowsFinancialControlling).Amount += _NettoDiff If _RegistryRowsFinancialControlling_Collection(0).ContractRows IsNot Nothing Then If _RegistryRowsFinancialControlling_Collection(0).ContractRows.CurrencyName.ShortName = "HUF" Then _RegistryRowsFinancialControlling_Collection(0).ContractRows.NettoPriceHUF = _RegistryRowsFinancialControlling_Collection(0).Amount Else _RegistryRowsFinancialControlling_Collection(0).ContractRows.NettoPriceHUF = _RegistryRowsFinancialControlling_Collection(0).Amount _RegistryRowsFinancialControlling_Collection(0).ContractRows.NettoPriceDEV = _RegistryRowsFinancialControlling_Collection(0).ContractRows.NettoPriceHUF * _RegistryHeader.F_CurrencyRate End If End If End If End If End Sub End Class