Files
2017-03-08 11:21:27 +01:00

1407 lines
96 KiB
VB.net

Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text
Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base
Imports DevExpress.Xpo
Imports DevExpress.Data.Filtering
Imports System.Linq
Imports DevExpress.ExpressApp.Model
Public Class FixedassetsCardVC
Inherits DevExpress.ExpressApp.ViewController
Public Event InitWork(ByVal _Minimum As Long, ByVal _Step As Long, ByVal _Maximum As Long)
Public Event DoWork()
Public Event FinalWork
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()
RegisterActions(components)
End Sub
Protected Overrides Sub OnActivated()
MyBase.OnActivated()
If View.Id = "FixedAssetsCard_OpenYear_PopUp_DetailView" Then
AddHandler Frame.GetController(Of DevExpress.ExpressApp.SystemModule.DialogController)().AcceptAction.Executing, AddressOf FixedAssetsCard_OpenYear_PopUp_AcceptAction_Executing
End If
End Sub
Private Sub aFinalize_FixedAssetsCard_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs) Handles aFinalize_FixedAssetsCard.Execute
Try
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _FixedAssetsCard As FixedAssetsCard
For Each _FixedAssetsCard In View.SelectedObjects
If _FixedAssetsCard.IsActivated = True Then
Activate_FixedAssets(_ocur, _FixedAssetsCard)
End If
Next
If TryCast(View, DetailView) IsNot Nothing Then
View.Close()
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Hiba!")
End Try
End Sub
Private Sub aFixedAssetsCard_ReActivate_CustomizePopupWindowParams(sender As Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aFixedAssetsCard_ReActivate.CustomizePopupWindowParams
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _FixedAssetsReactivationPopup As FixedAssetsReactivationPopup = _onew.CreateObject(Of FixedAssetsReactivationPopup)()
_FixedAssetsReactivationPopup.DateExecution = GetSQLTime(_onew.Session)
e.View = Application.CreateDetailView(_onew, "FixedAssetsReactivationPopup_DetailView", False, _FixedAssetsReactivationPopup)
End Sub
Private Sub aFixedAssetsCard_ReActivate_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aFixedAssetsCard_ReActivate.Execute
End Sub
Private Sub aFixedAssetsCard_Terminate_CustomizePopupWindowParams(sender As Object, e As DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs) Handles aFixedAssetsCard_Terminate.CustomizePopupWindowParams
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _FixedAssetsTerminatePopup As FixedAssetsTerminatePopup = _onew.CreateObject(Of FixedAssetsTerminatePopup)()
_FixedAssetsTerminatePopup.DateExecution = GetSQLTime(_onew.Session)
e.View = Application.CreateDetailView(_onew, "FixedAssetsTerminatePopup_DetailView", False, _FixedAssetsTerminatePopup)
End Sub
Private Sub aFixedAssetsCard_Terminate_Execute(sender As System.Object, e As DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs) Handles aFixedAssetsCard_Terminate.Execute
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _FixedAssetsCard As FixedAssetsCard = TryCast(View.SelectedObjects(0), FixedAssetsCard)
Dim _FixedAssetsTerminatePopup As FixedAssetsTerminatePopup = TryCast(e.PopupWindow.View.SelectedObjects(0), FixedAssetsTerminatePopup)
If _FixedAssetsCard IsNot Nothing Then
If _FixedAssetsCard.IsTerminal = False And _FixedAssetsCard.IsActivated = True And _FixedAssetsCard.IsEditable = False Then
Terminate_FixedAssets(_ocur, _FixedAssetsCard, _FixedAssetsTerminatePopup)
End If
End If
End Sub
Private Sub aFixedAssetsCard_Terminate_Storno_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aFixedAssetsCard_Terminate_Storno.Execute
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _FixedAssetsCard As FixedAssetsCard = TryCast(View.SelectedObjects(0), FixedAssetsCard)
If _FixedAssetsCard IsNot Nothing Then
If _FixedAssetsCard.IsTerminal = True Then
Terminate_Storno_FixedAssets(_ocur, _FixedAssetsCard)
End If
End If
End Sub
Private Sub aFixedAssetsCard_Activate_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aFixedAssetsCard_Activate.Execute
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _FixedAssetsCard As FixedAssetsCard
For Each _FixedAssetsCard In View.SelectedObjects
If _FixedAssetsCard.IsActivated = False Then
Activate_FixedAssets(_ocur, _FixedAssetsCard)
If Not _FixedAssetsCard.IsNew Then
RegenerateReceivedFromAnotherSystem(_ocur, _FixedAssetsCard)
End If
End If
Next
End Sub
Private Sub aFixedAssetsCard_Activate_Storno_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles aFixedAssetsCard_Activate_Storno.Execute
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _FixedAssetsCard As FixedAssetsCard
For Each _FixedAssetsCard In View.SelectedObjects
If _FixedAssetsCard.IsActivated = True Then
Activate_Storno_FixedAssets(_ocur, _FixedAssetsCard)
End If
Next
End Sub
Private Sub aFixedAssetsCard_OpenYear_CustomizePopupWindowParams(sender As Object, e As CustomizePopupWindowParamsEventArgs) Handles aFixedAssetsCard_OpenYear.CustomizePopupWindowParams
Dim _onew As Xpo.XPObjectSpace = Application.CreateObjectSpace
Dim _FixedAssetsCard_OpenYear_PopUp As New FixedAssetsCard_OpenYear_PopUp(_onew.Session)
e.View = Application.CreateDetailView(_onew, "FixedAssetsCard_OpenYear_PopUp_DetailView", False, _FixedAssetsCard_OpenYear_PopUp)
End Sub
Private Sub aFixedAssetsCard_OpenYear_Execute(sender As Object, e As PopupWindowShowActionExecuteEventArgs) Handles aFixedAssetsCard_OpenYear.Execute
Dim _ocur As Xpo.XPObjectSpace = TryCast(View.ObjectSpace, Xpo.XPObjectSpace)
Dim _FixedAssetsCard_Collection As New XPCollection(Of FixedAssetsCard)(_ocur.Session, CriteriaOperator.Parse("IsTerminal=False AND IsActivated=True AND IsEditable=False"))
Dim _NewYear As Long = TryCast(e.PopupWindow.View.SelectedObjects(0), FixedAssetsCard_OpenYear_PopUp).TargetYear
If _FixedAssetsCard_Collection.Count > 0 Then
For Each _FixedAssetsCard As FixedAssetsCard In _FixedAssetsCard_Collection
Dim _FixedAssetsCardPlanRows_Collection As New XPCollection(Of FixedAssetsCardPlanRows)(_ocur.Session, CriteriaOperator.Parse("FixedAssetsCard=?", _FixedAssetsCard))
If _FixedAssetsCardPlanRows_Collection.Count > 0 Then
Dim _FixedAssetsCardPlanRows_Collection_NEW As New ArrayList
_FixedAssetsCardPlanRows_Collection.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending))
Dim _FixedAssetsCardPlanRows_Activated As FixedAssetsCardPlanRows = _FixedAssetsCardPlanRows_Collection(_FixedAssetsCardPlanRows_Collection.Count - 1)
'ÉCS
Dim _DecrepationPeriodAmountACC As Double = 0
Dim _DecrepationPeriodAmountTAX As Double = 0
Dim _StartDate As Date = _FixedAssetsCardPlanRows_Activated.DateTo.AddDays(1)
Dim _EndDate As New Date(_NewYear, 12, 31)
Dim _FullDayCount As Long = DateDiff(DateInterval.Day, _StartDate, _EndDate)
Dim _RowIndex As Long = _FixedAssetsCardPlanRows_Collection(_FixedAssetsCardPlanRows_Collection.Count - 1).RowIndex + 1
Select Case _FixedAssetsCard.DCPAccounting.FixedAssetsPeriod
Case eFixedAssetsPeriod.eMonth
'_DecrepationPeriodAmountACC = _FixedAssetsCardPlanRows_Activated.BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyACC / 100 / 12
'_DecrepationPeriodAmountTAX = _FixedAssetsCardPlanRows_Activated.BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyTax / 100 / 12
'Dim _ActYear As Date = New Date(_StartDate.Year, _StartDate.Month, 1)
'Dim _DateFrom As Date = _StartDate
'Dim _DateTo As Date = New Date(_ActYear.Year, _ActYear.Month + 1, 1).AddDays(-1)
'Do
' Dim _FixedAssetsCardPlanRows As New FixedAssetsCardPlanRows(_ocur.Session)
' With _FixedAssetsCardPlanRows
' .FixedAssetsCard = _FixedAssetsCard
' .RowIndex = _RowIndex
' .FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
' .DateFrom = _DateFrom
' .DateTo = _DateTo
' .DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
' .DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
' .KeyACC = _FixedAssetsCard.DCPAccounting.DecrepationPercent
' .KeyTax = _FixedAssetsCard.DCPTax.DecrepationPercent
' .SalvageHUF = _FixedAssetsCard.AmountHUFSalvage
' End With
' _RowIndex += 1
' _ActYear = _DateTo
' _DateFrom = _DateTo.AddDays(1)
' _DateTo = (New Date(_DateFrom.Year, _DateFrom.Month, 1).AddMonths(1)).AddDays(-1)
' _FixedAssetsCardPlanRows_Collection_NEW.Add(_FixedAssetsCardPlanRows)
'Loop While New Date(Now.Year, Now.Month + 1, 1).AddDays(-1) >= _ActYear
'Dim _NettoHUFBallanceACC As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).NettoHUFBallanceACC
'Dim _NettoHUFBallanceTAX As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).NettoHUFBallanceTAX
'Dim _BruttoHUFBallance As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).BruttoHUFBallance
'For ik = 1 To _FixedAssetsCardPlanRows_Collection_NEW.Count - 1
' Dim _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(ik), FixedAssetsCardPlanRows)
' With _FixedAssetsCardPlanRows
' Dim _ActMounthDayCount As Long = DateDiff(DateInterval.Day, New Date(.DateFrom.Year, .DateFrom.Month, 1), .DateTo) + 1
' .DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActMounthDayCount, 0, MidpointRounding.AwayFromZero)
' .DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActMounthDayCount, 0, MidpointRounding.AwayFromZero)
' .DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
' .DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
' If _NettoHUFBallanceACC <> 0 Then
' If _NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
' .DecrepationHUFACC = _NettoHUFBallanceACC - .SalvageHUF
' .NettoHUFBallanceACC = .SalvageHUF
' _NettoHUFBallanceACC = 0
' .DayCountACC = Math.Round(.DecrepationHUFACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
' Else
' .NettoHUFBallanceACC = _NettoHUFBallanceACC - .DecrepationHUFACC
' End If
' Else
' .NettoHUFBallanceACC = .SalvageHUF
' .DayDecrepationACC = 0
' .DecrepationHUFACC = 0
' .DayCountACC = 0
' End If
' If _NettoHUFBallanceTAX <> 0 Then
' If _NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
' .DecrepationHUFTAX = _NettoHUFBallanceTAX
' .NettoHUFBallanceTAX = 0
' _NettoHUFBallanceTAX = 0
' .DayCountTAX = Math.Round(.DecrepationHUFTAX / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
' Else
' .NettoHUFBallanceTAX = _NettoHUFBallanceTAX - .DecrepationHUFTAX
' End If
' Else
' .NettoHUFBallanceTAX = 0
' .DayDecrepationTAX = 0
' .DecrepationHUFTAX = 0
' .DayCountTAX = 0
' End If
' .BruttoHUF = 0
' .BruttoHUFBallance = _BruttoHUFBallance
' End With
' If _FixedAssetsCardPlanRows.NettoHUFBallanceACC <> 0 And _NettoHUFBallanceACC <> 0 Then
' _NettoHUFBallanceACC = _FixedAssetsCardPlanRows.NettoHUFBallanceACC
' End If
' If _FixedAssetsCardPlanRows.NettoHUFBallanceTAX <> 0 Then
' _NettoHUFBallanceTAX = _FixedAssetsCardPlanRows.NettoHUFBallanceTAX
' End If
' _BruttoHUFBallance = _FixedAssetsCardPlanRows.BruttoHUFBallance
'Next
Case eFixedAssetsPeriod.eQuarter
'_DecrepationPeriodAmountACC = _FixedAssetsCardPlanRows_Collection(0).BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyACC / 100 / 4
'_DecrepationPeriodAmountTAX = _FixedAssetsCardPlanRows_Collection(0).BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyTax / 100 / 4
'Dim _ActYear As Date = New Date(_StartDate.Year, _StartDate.Month, 1)
'Dim _DateFrom As Date = _StartDate
'Dim _DateTo As Date
'If _StartDate >= New Date(_StartDate.Year, 1, 1) And _StartDate <= New Date(_StartDate.Year, 3, 31) Then
' _DateTo = New Date(_StartDate.Year, 3, 31)
'End If
'If _StartDate >= New Date(_StartDate.Year, 4, 1) And _StartDate <= New Date(_StartDate.Year, 6, 30) Then
' _DateTo = New Date(_StartDate.Year, 6, 30)
'End If
'If _StartDate >= New Date(_StartDate.Year, 7, 1) And _StartDate <= New Date(_StartDate.Year, 9, 30) Then
' _DateTo = New Date(_StartDate.Year, 9, 30)
'End If
'If _StartDate >= New Date(_StartDate.Year, 10, 1) And _StartDate <= New Date(_StartDate.Year, 12, 31) Then
' _DateTo = New Date(_StartDate.Year, 12, 31)
'End If
'Do
' Dim _FixedAssetsCardPlanRows As New FixedAssetsCardPlanRows(_ocur.Session)
' With _FixedAssetsCardPlanRows
' .FixedAssetsCard = _FixedAssetsCard
' .RowIndex = _RowIndex
' .FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
' .DateFrom = _DateFrom
' .DateTo = _DateTo
' .DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
' .DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
' .KeyACC = _FixedAssetsCard.DCPAccounting.DecrepationPercent
' .KeyTax = _FixedAssetsCard.DCPTax.DecrepationPercent
' .SalvageHUF = _FixedAssetsCard.AmountHUFSalvage
' End With
' _RowIndex += 1
' _ActYear = _DateTo
' _DateFrom = _DateTo.AddDays(1)
' _DateTo = (New Date(_DateFrom.Year, _DateFrom.Month, 1).AddMonths(3)).AddDays(-1)
' _FixedAssetsCardPlanRows_Collection_NEW.Add(_FixedAssetsCardPlanRows)
'Loop While _EndDate >= _ActYear
'Dim _NettoHUFBallanceACC As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).NettoHUFBallanceACC
'Dim _NettoHUFBallanceTAX As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).NettoHUFBallanceTAX
'Dim _BruttoHUFBallance As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).BruttoHUFBallance
'For ik = 1 To _FixedAssetsCardPlanRows_Collection_NEW.Count - 1
' Dim _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(ik), FixedAssetsCardPlanRows)
' With _FixedAssetsCardPlanRows
' Dim _ActQuarterDayCount As Long = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
' .DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActQuarterDayCount, 0, MidpointRounding.AwayFromZero)
' .DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActQuarterDayCount, 0, MidpointRounding.AwayFromZero)
' .DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
' .DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
' If _NettoHUFBallanceACC <> 0 Then
' If _NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
' .DecrepationHUFACC = _NettoHUFBallanceACC - .SalvageHUF
' .NettoHUFBallanceACC = .SalvageHUF
' _NettoHUFBallanceACC = 0
' .DayCountACC = Math.Round(.DecrepationHUFACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
' Else
' .NettoHUFBallanceACC = _NettoHUFBallanceACC - .DecrepationHUFACC
' End If
' Else
' .NettoHUFBallanceACC = .SalvageHUF
' .DayDecrepationACC = 0
' .DecrepationHUFACC = 0
' .DayCountACC = 0
' End If
' If _NettoHUFBallanceTAX <> 0 Then
' If _NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
' .DecrepationHUFTAX = _NettoHUFBallanceTAX
' .NettoHUFBallanceTAX = 0
' _NettoHUFBallanceTAX = 0
' .DayCountTAX = Math.Round(.DecrepationHUFTAX / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
' Else
' .NettoHUFBallanceTAX = _NettoHUFBallanceTAX - .DecrepationHUFTAX
' End If
' Else
' .NettoHUFBallanceTAX = 0
' .DayDecrepationTAX = 0
' .DecrepationHUFTAX = 0
' .DayCountTAX = 0
' End If
' .BruttoHUF = 0
' .BruttoHUFBallance = _BruttoHUFBallance
' End With
' If _FixedAssetsCardPlanRows.NettoHUFBallanceACC <> 0 And _NettoHUFBallanceACC <> 0 Then
' _NettoHUFBallanceACC = _FixedAssetsCardPlanRows.NettoHUFBallanceACC
' End If
' If _FixedAssetsCardPlanRows.NettoHUFBallanceTAX <> 0 Then
' _NettoHUFBallanceTAX = _FixedAssetsCardPlanRows.NettoHUFBallanceTAX
' End If
' _BruttoHUFBallance = _FixedAssetsCardPlanRows.BruttoHUFBallance
'Next
Case eFixedAssetsPeriod.eYear
_DecrepationPeriodAmountACC = _FixedAssetsCardPlanRows_Collection(0).BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyACC / 100
_DecrepationPeriodAmountTAX = _FixedAssetsCardPlanRows_Collection(0).BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyTax / 100
Dim _ActYear As Long = _StartDate.Year
Dim _DateFrom As Date = _StartDate
Dim _DateTo As Date = New Date(_ActYear + 1, 1, 1).AddDays(-1)
Do
Dim _FixedAssetsCardPlanRows As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _RowIndex
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.DateFrom = _DateFrom
.DateTo = _DateTo
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.KeyACC = _FixedAssetsCard.DCPAccounting.DecrepationPercent
.KeyTax = _FixedAssetsCard.DCPTax.DecrepationPercent
.SalvageHUF = _FixedAssetsCard.AmountHUFSalvage
End With
_RowIndex += 1
_ActYear += 1
_DateFrom = _DateTo.AddDays(1)
_DateTo = New Date(_DateFrom.Year + 1, 1, 1).AddDays(-1)
_FixedAssetsCardPlanRows_Collection_NEW.Add(_FixedAssetsCardPlanRows)
Loop While _NewYear >= _ActYear
Dim _NettoHUFBallanceACC As Double = _FixedAssetsCardPlanRows_Activated.NettoHUFBallanceACC
Dim _NettoHUFBallanceTAX As Double = _FixedAssetsCardPlanRows_Activated.NettoHUFBallanceTAX
Dim _BruttoHUFBallance As Double = _FixedAssetsCardPlanRows_Activated.BruttoHUFBallance
For ik = 0 To _FixedAssetsCardPlanRows_Collection_NEW.Count - 1
Dim _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(ik), FixedAssetsCardPlanRows)
With _FixedAssetsCardPlanRows
Dim _ActYearDayCount As Long = DateDiff(DateInterval.Day, New Date(.DateFrom.Year, 1, 1), .DateTo) + 1
.DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActYearDayCount, 0, MidpointRounding.AwayFromZero)
.DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActYearDayCount, 0, MidpointRounding.AwayFromZero)
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
If _NettoHUFBallanceACC <> 0 Then
If _NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
_NettoHUFBallanceACC = 0
.DayCountACC = Math.Round(.NettoHUFBallanceACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _NettoHUFBallanceACC - .DecrepationHUFACC
End If
Else
.NettoHUFBallanceACC = .SalvageHUF
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.DayCountACC = 0
End If
If _NettoHUFBallanceTAX <> 0 Then
If _NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
_NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.NettoHUFBallanceACC / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
Else
.NettoHUFBallanceTAX = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.DayCountTAX = 0
End If
.BruttoHUF = 0
.BruttoHUFBallance = _BruttoHUFBallance
End With
If _FixedAssetsCardPlanRows.NettoHUFBallanceACC <> 0 And _NettoHUFBallanceACC <> 0 Then
_NettoHUFBallanceACC = _FixedAssetsCardPlanRows.NettoHUFBallanceACC
End If
If _FixedAssetsCardPlanRows.NettoHUFBallanceTAX <> 0 Then
_NettoHUFBallanceTAX = _FixedAssetsCardPlanRows.NettoHUFBallanceTAX
End If
_BruttoHUFBallance = _FixedAssetsCardPlanRows.BruttoHUFBallance
Next
End Select
End If
_FixedAssetsCard.IsEditable = False
_FixedAssetsCard.IsActivated = True
_ocur.CommitChanges()
Next
End If
End Sub
#Region "FIXED ASSETS TRANSACTIONS"
Private Sub Activate_FixedAssets(_ocur As Xpo.XPObjectSpace, _FixedAssetsCard As FixedAssetsCard)
Dim _FixedAssetsCardPlanRows_Collection As New XPCollection(Of FixedAssetsCardPlanRows)(_ocur.Session, CriteriaOperator.Parse("FixedAssetsCard=?", _FixedAssetsCard))
If _FixedAssetsCardPlanRows_Collection.Count > 0 Then Throw New Exception(String.Format("A(z) {0} tárgyieszköz már aktiválva lett!", _FixedAssetsCard.UniqueObjects.Name))
Dim _FixedAssetsCardPlanRows_Collection_NEW As New ArrayList
Dim _FixedAssetsCardPlanRows_Activated As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows_Activated
.FixedAssetsCard = _FixedAssetsCard
.DateFrom = _FixedAssetsCard.DateActivation
.DateTo = _FixedAssetsCard.DateActivation
.RowIndex = 1
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eActivated
.DateExecution = _FixedAssetsCard.DateActivation
.DayCountACC = 0
.DayCountTAX = 0
.KeyACC = _FixedAssetsCard.DCPAccounting.DecrepationPercent
.KeyTax = _FixedAssetsCard.DCPTax.DecrepationPercent
.BruttoHUF = _FixedAssetsCard.AmountHUFBrutto
.SalvageHUF = _FixedAssetsCard.AmountHUFSalvage
.SalvageHUFBallance = .SalvageHUF
.DayDecrepationTAX = 0
.DayDecrepationACC = 0
.BruttoHUFBallance = .BruttoHUF
.DecrepationHUFACC = 0
.NettoHUFBallanceACC = .BruttoHUFBallance - .DecrepationHUFACC
.DecrepationHUFTAX = 0
.NettoHUFBallanceTAX = .BruttoHUFBallance - .DecrepationHUFTAX
.BruttoHUFTerminal = 0
.NettoHUFTerminalACC = 0
End With
If _FixedAssetsCard.DCPAccounting.FixedAssetsSpecies = eFixedAssetsSpecies.eSmallValueOfFixedAssets Then
'// Kisérték esetén !!!
Dim _FixedAssetsCardPlanRows As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = 2
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.DateFrom = _FixedAssetsCard.DateActivation
.DateTo = _FixedAssetsCard.DateActivation
.DayCountACC = 1
.DayCountTAX = 1
.KeyACC = _FixedAssetsCard.DCPAccounting.DecrepationPercent
.KeyTax = _FixedAssetsCard.DCPTax.DecrepationPercent
.SalvageHUF = 0
.BruttoHUFBallance = _FixedAssetsCard.AmountHUFBrutto
.DecrepationHUFACC = _FixedAssetsCard.AmountHUFBrutto
.NettoHUFBallanceACC = 0
.DecrepationHUFTAX = _FixedAssetsCard.AmountHUFBrutto
.NettoHUFBallanceTAX = 0
End With
Else
_FixedAssetsCardPlanRows_Collection_NEW.Add(_FixedAssetsCardPlanRows_Activated)
'ÉCS
Dim _DecrepationPeriodAmountACC As Double = 0
Dim _DecrepationPeriodAmountTAX As Double = 0
Dim _StartDate As Date = _FixedAssetsCard.DateActivation
Dim _EndDate As New Date(Now.Year, 12, 31)
Dim _FullDayCount As Long = DateDiff(DateInterval.Day, _StartDate, _EndDate)
Dim _RowIndex As Long = 2
Select Case _FixedAssetsCard.DCPAccounting.FixedAssetsPeriod
Case eFixedAssetsPeriod.eMonth
_DecrepationPeriodAmountACC = _FixedAssetsCardPlanRows_Activated.BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyACC / 100 / 12
_DecrepationPeriodAmountTAX = _FixedAssetsCardPlanRows_Activated.BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyTax / 100 / 12
Dim _ActYear As Date = New Date(_StartDate.Year, _StartDate.Month, 1)
Dim _DateFrom As Date = _StartDate
Dim _DateTo As Date = New Date(_ActYear.Year, _ActYear.Month + 1, 1).AddDays(-1)
Do
Dim _FixedAssetsCardPlanRows As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _RowIndex
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.DateFrom = _DateFrom
.DateTo = _DateTo
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.KeyACC = _FixedAssetsCard.DCPAccounting.DecrepationPercent
.KeyTax = _FixedAssetsCard.DCPTax.DecrepationPercent
.SalvageHUF = _FixedAssetsCard.AmountHUFSalvage
End With
_RowIndex += 1
_ActYear = _DateTo
_DateFrom = _DateTo.AddDays(1)
_DateTo = (New Date(_DateFrom.Year, _DateFrom.Month, 1).AddMonths(1)).AddDays(-1)
_FixedAssetsCardPlanRows_Collection_NEW.Add(_FixedAssetsCardPlanRows)
Loop While New Date(Now.Year, Now.Month + 1, 1).AddDays(-1) >= _ActYear
Dim _NettoHUFBallanceACC As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).NettoHUFBallanceACC
Dim _NettoHUFBallanceTAX As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).NettoHUFBallanceTAX
Dim _BruttoHUFBallance As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).BruttoHUFBallance
For ik = 1 To _FixedAssetsCardPlanRows_Collection_NEW.Count - 1
Dim _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(ik), FixedAssetsCardPlanRows)
With _FixedAssetsCardPlanRows
Dim _ActMounthDayCount As Long = DateDiff(DateInterval.Day, New Date(.DateFrom.Year, .DateFrom.Month, 1), .DateTo) + 1
.DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActMounthDayCount, 0, MidpointRounding.AwayFromZero)
.DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActMounthDayCount, 0, MidpointRounding.AwayFromZero)
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
If _NettoHUFBallanceACC <> 0 Then
If _NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
_NettoHUFBallanceACC = 0
.DayCountACC = Math.Round(.DecrepationHUFACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _NettoHUFBallanceACC - .DecrepationHUFACC
End If
Else
.NettoHUFBallanceACC = .SalvageHUF
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.DayCountACC = 0
End If
If _NettoHUFBallanceTAX <> 0 Then
If _NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
_NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.DecrepationHUFTAX / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
Else
.NettoHUFBallanceTAX = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.DayCountTAX = 0
End If
.BruttoHUF = 0
.BruttoHUFBallance = _BruttoHUFBallance
End With
If _FixedAssetsCardPlanRows.NettoHUFBallanceACC <> 0 And _NettoHUFBallanceACC <> 0 Then
_NettoHUFBallanceACC = _FixedAssetsCardPlanRows.NettoHUFBallanceACC
End If
If _FixedAssetsCardPlanRows.NettoHUFBallanceTAX <> 0 Then
_NettoHUFBallanceTAX = _FixedAssetsCardPlanRows.NettoHUFBallanceTAX
End If
_BruttoHUFBallance = _FixedAssetsCardPlanRows.BruttoHUFBallance
Next
Case eFixedAssetsPeriod.eQuarter
_DecrepationPeriodAmountACC = _FixedAssetsCardPlanRows_Activated.BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyACC / 100 / 4
_DecrepationPeriodAmountTAX = _FixedAssetsCardPlanRows_Activated.BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyTax / 100 / 4
Dim _ActYear As Date = New Date(_StartDate.Year, _StartDate.Month, 1)
Dim _DateFrom As Date = _StartDate
Dim _DateTo As Date
If _StartDate >= New Date(_StartDate.Year, 1, 1) And _StartDate <= New Date(_StartDate.Year, 3, 31) Then
_DateTo = New Date(_StartDate.Year, 3, 31)
End If
If _StartDate >= New Date(_StartDate.Year, 4, 1) And _StartDate <= New Date(_StartDate.Year, 6, 30) Then
_DateTo = New Date(_StartDate.Year, 6, 30)
End If
If _StartDate >= New Date(_StartDate.Year, 7, 1) And _StartDate <= New Date(_StartDate.Year, 9, 30) Then
_DateTo = New Date(_StartDate.Year, 9, 30)
End If
If _StartDate >= New Date(_StartDate.Year, 10, 1) And _StartDate <= New Date(_StartDate.Year, 12, 31) Then
_DateTo = New Date(_StartDate.Year, 12, 31)
End If
Do
Dim _FixedAssetsCardPlanRows As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _RowIndex
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.DateFrom = _DateFrom
.DateTo = _DateTo
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.KeyACC = _FixedAssetsCard.DCPAccounting.DecrepationPercent
.KeyTax = _FixedAssetsCard.DCPTax.DecrepationPercent
.SalvageHUF = _FixedAssetsCard.AmountHUFSalvage
End With
_RowIndex += 1
_ActYear = _DateTo
_DateFrom = _DateTo.AddDays(1)
_DateTo = (New Date(_DateFrom.Year, _DateFrom.Month, 1).AddMonths(3)).AddDays(-1)
_FixedAssetsCardPlanRows_Collection_NEW.Add(_FixedAssetsCardPlanRows)
Loop While _EndDate >= _ActYear
Dim _NettoHUFBallanceACC As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).NettoHUFBallanceACC
Dim _NettoHUFBallanceTAX As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).NettoHUFBallanceTAX
Dim _BruttoHUFBallance As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).BruttoHUFBallance
For ik = 1 To _FixedAssetsCardPlanRows_Collection_NEW.Count - 1
Dim _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(ik), FixedAssetsCardPlanRows)
With _FixedAssetsCardPlanRows
Dim _ActQuarterDayCount As Long = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActQuarterDayCount, 0, MidpointRounding.AwayFromZero)
.DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActQuarterDayCount, 0, MidpointRounding.AwayFromZero)
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
If _NettoHUFBallanceACC <> 0 Then
If _NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
_NettoHUFBallanceACC = 0
.DayCountACC = Math.Round(.DecrepationHUFACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _NettoHUFBallanceACC - .DecrepationHUFACC
End If
Else
.NettoHUFBallanceACC = .SalvageHUF
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.DayCountACC = 0
End If
If _NettoHUFBallanceTAX <> 0 Then
If _NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
_NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.DecrepationHUFTAX / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
Else
.NettoHUFBallanceTAX = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.DayCountTAX = 0
End If
.BruttoHUF = 0
.BruttoHUFBallance = _BruttoHUFBallance
End With
If _FixedAssetsCardPlanRows.NettoHUFBallanceACC <> 0 And _NettoHUFBallanceACC <> 0 Then
_NettoHUFBallanceACC = _FixedAssetsCardPlanRows.NettoHUFBallanceACC
End If
If _FixedAssetsCardPlanRows.NettoHUFBallanceTAX <> 0 Then
_NettoHUFBallanceTAX = _FixedAssetsCardPlanRows.NettoHUFBallanceTAX
End If
_BruttoHUFBallance = _FixedAssetsCardPlanRows.BruttoHUFBallance
Next
Case eFixedAssetsPeriod.eYear
_DecrepationPeriodAmountACC = _FixedAssetsCardPlanRows_Activated.BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyACC / 100
_DecrepationPeriodAmountTAX = _FixedAssetsCardPlanRows_Activated.BruttoHUF * _FixedAssetsCardPlanRows_Activated.KeyTax / 100
Dim _ActYear As Long = _StartDate.Year
Dim _DateFrom As Date = _StartDate
Dim _DateTo As Date = New Date(_ActYear + 1, 1, 1).AddDays(-1)
Do
Dim _FixedAssetsCardPlanRows As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _RowIndex
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.DateFrom = _DateFrom
.DateTo = _DateTo
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.KeyACC = _FixedAssetsCard.DCPAccounting.DecrepationPercent
.KeyTax = _FixedAssetsCard.DCPTax.DecrepationPercent
.SalvageHUF = _FixedAssetsCard.AmountHUFSalvage
End With
_RowIndex += 1
_ActYear += 1
_DateFrom = _DateTo.AddDays(1)
_DateTo = New Date(_DateFrom.Year + 1, 1, 1).AddDays(-1)
_FixedAssetsCardPlanRows_Collection_NEW.Add(_FixedAssetsCardPlanRows)
Loop While Now.Year >= _ActYear
Dim _NettoHUFBallanceACC As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).NettoHUFBallanceACC
Dim _NettoHUFBallanceTAX As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).NettoHUFBallanceTAX
Dim _BruttoHUFBallance As Double = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(0), FixedAssetsCardPlanRows).BruttoHUFBallance
For ik = 1 To _FixedAssetsCardPlanRows_Collection_NEW.Count - 1
Dim _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(ik), FixedAssetsCardPlanRows)
With _FixedAssetsCardPlanRows
Dim _ActYearDayCount As Long = DateDiff(DateInterval.Day, New Date(.DateFrom.Year, 1, 1), .DateTo) + 1
.DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActYearDayCount, 0, MidpointRounding.AwayFromZero)
.DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActYearDayCount, 0, MidpointRounding.AwayFromZero)
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
If _NettoHUFBallanceACC <> 0 Then
If _NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
_NettoHUFBallanceACC = 0
.DayCountACC = Math.Round(.NettoHUFBallanceACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _NettoHUFBallanceACC - .DecrepationHUFACC
End If
Else
.NettoHUFBallanceACC = .SalvageHUF
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.DayCountACC = 0
End If
If _NettoHUFBallanceTAX <> 0 Then
If _NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
_NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.NettoHUFBallanceACC / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
Else
.NettoHUFBallanceTAX = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.DayCountTAX = 0
End If
.BruttoHUF = 0
.BruttoHUFBallance = _BruttoHUFBallance
End With
If _FixedAssetsCardPlanRows.NettoHUFBallanceACC <> 0 And _NettoHUFBallanceACC <> 0 Then
_NettoHUFBallanceACC = _FixedAssetsCardPlanRows.NettoHUFBallanceACC
End If
If _FixedAssetsCardPlanRows.NettoHUFBallanceTAX <> 0 Then
_NettoHUFBallanceTAX = _FixedAssetsCardPlanRows.NettoHUFBallanceTAX
End If
_BruttoHUFBallance = _FixedAssetsCardPlanRows.BruttoHUFBallance
Next
End Select
End If
_FixedAssetsCard.IsEditable = False
_FixedAssetsCard.IsActivated = True
_ocur.CommitChanges()
End Sub
Private Sub Activate_Storno_FixedAssets(_ocur As Xpo.XPObjectSpace, _FixedAssetsCard As FixedAssetsCard)
If _FixedAssetsCard.IsActivated Then
Dim _FixedAssetsCardPlanRows_Collection As New XPCollection(Of FixedAssetsCardPlanRows)(_ocur.Session, CriteriaOperator.Parse("FixedAssetsCard=?", _FixedAssetsCard))
If _FixedAssetsCardPlanRows_Collection.Count > 0 Then
_ocur.Delete(_FixedAssetsCardPlanRows_Collection)
End If
_FixedAssetsCard.IsActivated = False
_ocur.CommitChanges()
End If
End Sub
Private Sub Terminate_FixedAssets(_ocur As Xpo.XPObjectSpace, _FixedAssetsCard As FixedAssetsCard, _FixedAssetsTerminatePopup As FixedAssetsTerminatePopup)
Dim _FixedAssetsCardPlanRows_Collection_DEL As New ArrayList
If _FixedAssetsTerminatePopup IsNot Nothing Then
Select Case _FixedAssetsCard.DCPAccounting.FixedAssetsPeriod
Case eFixedAssetsPeriod.eMonth
Dim _TerminalStart As Date = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, _FixedAssetsTerminatePopup.DateExecution.Month, 1)
Dim _TerminalEnd As Date = (New Date(_FixedAssetsTerminatePopup.DateExecution.Year, _FixedAssetsTerminatePopup.DateExecution.Month, 1).AddMonths(1)).AddDays(-1)
Dim _LastRowIndex = 0
_FixedAssetsCard.FixedAssetsCardPlanRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending))
For Each _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows In _FixedAssetsCard.FixedAssetsCardPlanRows
If _FixedAssetsCardPlanRows.DateFrom = _TerminalStart And _FixedAssetsCardPlanRows.DateTo = _TerminalEnd Then
_LastRowIndex = _FixedAssetsCardPlanRows.RowIndex - 1
End If
If _LastRowIndex <> 0 Then
_FixedAssetsCardPlanRows_Collection_DEL.Add(_FixedAssetsCardPlanRows)
End If
Next
Dim _FixedAssetsCardPlanRows_LastAvilable As FixedAssetsCardPlanRows = _ocur.FindObject(Of FixedAssetsCardPlanRows)(CriteriaOperator.Parse("FixedAssetsCard=? AND RowIndex=?", _FixedAssetsCard, _LastRowIndex))
Dim _DecrepationPeriodAmountACC As Double = _FixedAssetsCardPlanRows_LastAvilable.BruttoHUFBallance * _FixedAssetsCardPlanRows_LastAvilable.KeyACC / 100 / 12
Dim _DecrepationPeriodAmountTAX As Double = _FixedAssetsCardPlanRows_LastAvilable.BruttoHUFBallance * _FixedAssetsCardPlanRows_LastAvilable.KeyTax / 100 / 12
Dim _FixedAssetsCardPlanRows_NEW As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows_NEW
.DateFrom = _FixedAssetsCardPlanRows_LastAvilable.DateTo.AddDays(1)
.DateTo = _FixedAssetsTerminatePopup.DateExecution.AddDays(-1)
Dim _ActMonthDayCount As Long = DateDiff(DateInterval.Day, .DateFrom, (.DateFrom.AddMonths(1)).AddDays(-1))
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo)
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo)
.DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActMonthDayCount, 0, MidpointRounding.AwayFromZero)
.DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActMonthDayCount, 0, MidpointRounding.AwayFromZero)
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _LastRowIndex + 1
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.FixedAssetsTerminalReason = eFixedAssetsTerminalReason.eNone
.SalvageHUF = _FixedAssetsCardPlanRows_LastAvilable.SalvageHUF
If _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
.DayCountACC = Math.Round(.NettoHUFBallanceACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceACC - .DecrepationHUFACC
End If
If _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.NettoHUFBallanceACC / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
.BruttoHUF = 0
.BruttoHUFBallance = _FixedAssetsCardPlanRows_LastAvilable.BruttoHUFBallance
End With
Dim _FixedAssetsCardPlanRows_Terminal As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows_Terminal
.FixedAssetsTerminalReason = _FixedAssetsTerminatePopup.FixedAssetsTerminalReason
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _FixedAssetsCardPlanRows_NEW.RowIndex + 1
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eTerminate
.FixedAssetsTerminalReason = _FixedAssetsTerminatePopup.FixedAssetsTerminalReason
.DateExecution = _FixedAssetsTerminatePopup.DateExecution
.DayCountTAX = 0
.KeyTax = 0
.KeyACC = 0
' .BruttoHUF = 0
.BruttoHUFBallance = 0
.SalvageHUF = 0
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.NettoHUFBallanceACC = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.NettoHUFBallanceTAX = 0
.BruttoHUFTerminal = _FixedAssetsCardPlanRows_NEW.BruttoHUFBallance '.BruttoHUF
.NettoHUFTerminalACC = _FixedAssetsCardPlanRows_NEW.NettoHUFBallanceACC
End With
Case eFixedAssetsPeriod.eQuarter
Dim _TerminalStart As Date
Dim _TerminalEnd As Date
If _FixedAssetsTerminatePopup.DateExecution >= New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 1, 1) And _FixedAssetsTerminatePopup.DateExecution <= New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 3, 31) Then
_TerminalStart = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 1, 1)
_TerminalEnd = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 3, 31)
End If
If _FixedAssetsTerminatePopup.DateExecution >= New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 4, 1) And _FixedAssetsTerminatePopup.DateExecution <= New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 6, 30) Then
_TerminalStart = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 4, 1)
_TerminalEnd = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 6, 30)
End If
If _FixedAssetsTerminatePopup.DateExecution >= New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 7, 1) And _FixedAssetsTerminatePopup.DateExecution <= New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 9, 30) Then
_TerminalStart = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 7, 1)
_TerminalEnd = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 9, 30)
End If
If _FixedAssetsTerminatePopup.DateExecution >= New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 10, 1) And _FixedAssetsTerminatePopup.DateExecution <= New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 12, 31) Then
_TerminalStart = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 10, 1)
_TerminalEnd = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 12, 31)
End If
Dim _LastRowIndex = 0
_FixedAssetsCard.FixedAssetsCardPlanRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending))
For Each _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows In _FixedAssetsCard.FixedAssetsCardPlanRows
If _FixedAssetsCardPlanRows.DateFrom = _TerminalStart And _FixedAssetsCardPlanRows.DateTo = _TerminalEnd Then
_LastRowIndex = _FixedAssetsCardPlanRows.RowIndex - 1
End If
If _LastRowIndex <> 0 Then
_FixedAssetsCardPlanRows_Collection_DEL.Add(_FixedAssetsCardPlanRows)
End If
Next
Dim _FixedAssetsCardPlanRows_LastAvilable As FixedAssetsCardPlanRows = _ocur.FindObject(Of FixedAssetsCardPlanRows)(CriteriaOperator.Parse("FixedAssetsCard=? AND RowIndex=?", _FixedAssetsCard, _LastRowIndex))
Dim _DecrepationPeriodAmountACC As Double = _FixedAssetsCardPlanRows_LastAvilable.BruttoHUFBallance * _FixedAssetsCardPlanRows_LastAvilable.KeyACC / 100 / 4
Dim _DecrepationPeriodAmountTAX As Double = _FixedAssetsCardPlanRows_LastAvilable.BruttoHUFBallance * _FixedAssetsCardPlanRows_LastAvilable.KeyTax / 100 / 4
Dim _FixedAssetsCardPlanRows_NEW As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows_NEW
.DateFrom = _FixedAssetsCardPlanRows_LastAvilable.DateTo.AddDays(1)
.DateTo = _FixedAssetsTerminatePopup.DateExecution.AddDays(-1)
Dim _ActQuarterDayCount As Long = DateDiff(DateInterval.Day, .DateFrom, (.DateFrom.AddMonths(3)).AddDays(-1))
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo)
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo)
.DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActQuarterDayCount, 0, MidpointRounding.AwayFromZero)
.DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActQuarterDayCount, 0, MidpointRounding.AwayFromZero)
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _LastRowIndex + 1
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.FixedAssetsTerminalReason = eFixedAssetsTerminalReason.eNone
.SalvageHUF = _FixedAssetsCardPlanRows_LastAvilable.SalvageHUF
If _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
.DayCountACC = Math.Round(.NettoHUFBallanceACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceACC - .DecrepationHUFACC
End If
If _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.NettoHUFBallanceACC / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
.BruttoHUF = 0
.BruttoHUFBallance = _FixedAssetsCardPlanRows_LastAvilable.BruttoHUFBallance
End With
Dim _FixedAssetsCardPlanRows_Terminal As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows_Terminal
.FixedAssetsTerminalReason = _FixedAssetsTerminatePopup.FixedAssetsTerminalReason
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _FixedAssetsCardPlanRows_NEW.RowIndex + 1
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eTerminate
.FixedAssetsTerminalReason = _FixedAssetsTerminatePopup.FixedAssetsTerminalReason
.DateExecution = _FixedAssetsTerminatePopup.DateExecution
.DayCountACC = 0
.DayCountTAX = 0
.KeyTax = 0
.KeyACC = 0
' .BruttoHUF = 0
.BruttoHUFBallance = 0
.SalvageHUF = 0
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.NettoHUFBallanceACC = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.NettoHUFBallanceTAX = 0
.BruttoHUFTerminal = _FixedAssetsCardPlanRows_NEW.BruttoHUFBallance '.BruttoHUF
.NettoHUFTerminalACC = _FixedAssetsCardPlanRows_NEW.NettoHUFBallanceACC
End With
Case eFixedAssetsPeriod.eYear
Dim _TerminalStart As Date = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 1, 1)
Dim _TerminalEnd As Date = New Date(_FixedAssetsTerminatePopup.DateExecution.Year, 12, 31)
Dim _LastRowIndex = 0
_FixedAssetsCard.FixedAssetsCardPlanRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending))
For Each _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows In _FixedAssetsCard.FixedAssetsCardPlanRows
If _FixedAssetsCardPlanRows.DateFrom = _TerminalStart And _FixedAssetsCardPlanRows.DateTo = _TerminalEnd Then
_LastRowIndex = _FixedAssetsCardPlanRows.RowIndex - 1
End If
If _LastRowIndex <> 0 Then
_FixedAssetsCardPlanRows_Collection_DEL.Add(_FixedAssetsCardPlanRows)
End If
Next
Dim _FixedAssetsCardPlanRows_LastAvilable As FixedAssetsCardPlanRows = _ocur.FindObject(Of FixedAssetsCardPlanRows)(CriteriaOperator.Parse("FixedAssetsCard=? AND RowIndex=?", _FixedAssetsCard, _LastRowIndex))
Dim _DecrepationPeriodAmountACC As Double = _FixedAssetsCardPlanRows_LastAvilable.BruttoHUFBallance * _FixedAssetsCardPlanRows_LastAvilable.KeyACC / 100
Dim _DecrepationPeriodAmountTAX As Double = _FixedAssetsCardPlanRows_LastAvilable.BruttoHUFBallance * _FixedAssetsCardPlanRows_LastAvilable.KeyTax / 100
Dim _FixedAssetsCardPlanRows_NEW As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows_NEW
.DateFrom = _FixedAssetsCardPlanRows_LastAvilable.DateTo.AddDays(1)
.DateTo = _FixedAssetsTerminatePopup.DateExecution.AddDays(-1)
Dim _ActYearDayCount As Long = DateDiff(DateInterval.Day, New Date(.DateFrom.Year, 1, 1), New Date(.DateFrom.Year, 12, 31))
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo)
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo)
.DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActYearDayCount, 0, MidpointRounding.AwayFromZero)
.DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActYearDayCount, 0, MidpointRounding.AwayFromZero)
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _LastRowIndex + 1
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.FixedAssetsTerminalReason = eFixedAssetsTerminalReason.eNone
.SalvageHUF = _FixedAssetsCardPlanRows_LastAvilable.SalvageHUF
If _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
.DayCountACC = Math.Round(.NettoHUFBallanceACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceACC - .DecrepationHUFACC
End If
If _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.NettoHUFBallanceACC / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _FixedAssetsCardPlanRows_LastAvilable.NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
.BruttoHUF = 0
.BruttoHUFBallance = _FixedAssetsCardPlanRows_LastAvilable.BruttoHUFBallance
End With
Dim _FixedAssetsCardPlanRows_Terminal As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows_Terminal
.FixedAssetsTerminalReason = _FixedAssetsTerminatePopup.FixedAssetsTerminalReason
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _FixedAssetsCardPlanRows_NEW.RowIndex + 1
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eTerminate
.FixedAssetsTerminalReason = _FixedAssetsTerminatePopup.FixedAssetsTerminalReason
.DateExecution = _FixedAssetsTerminatePopup.DateExecution
.DayCountACC = 0
.DayCountTAX = 0
.KeyTax = 0
.KeyACC = 0
' .BruttoHUF = 0
.BruttoHUFBallance = 0
.SalvageHUF = 0
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.NettoHUFBallanceACC = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.NettoHUFBallanceTAX = 0
.BruttoHUFTerminal = _FixedAssetsCardPlanRows_NEW.BruttoHUFBallance '.BruttoHUF
.NettoHUFTerminalACC = _FixedAssetsCardPlanRows_NEW.NettoHUFBallanceACC
End With
End Select
End If
_ocur.Delete(_FixedAssetsCardPlanRows_Collection_DEL)
_ocur.CommitChanges()
End Sub
Private Sub Terminate_Storno_FixedAssets(_ocur As Xpo.XPObjectSpace, _FixedAssetsCard As FixedAssetsCard)
Dim _FixedAssetsCardPlanRows_Collection_DEL As New ArrayList
_FixedAssetsCard.FixedAssetsCardPlanRows.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending))
Select Case _FixedAssetsCard.DCPAccounting.FixedAssetsPeriod
Case eFixedAssetsPeriod.eMonth
Dim _FixedAssetsCardPlanRows_Last As FixedAssetsCardPlanRows = _FixedAssetsCard.FixedAssetsCardPlanRows(_FixedAssetsCard.FixedAssetsCardPlanRows.Count - 2)
Dim _FixedAssetsCardPlanRows_Collection_NEW As New ArrayList
Dim _DecrepationPeriodAmountACC As Double = _FixedAssetsCardPlanRows_Last.BruttoHUFBallance * _FixedAssetsCard.FixedAssetsCardPlanRows(0).KeyACC / 100 / 12
Dim _DecrepationPeriodAmountTAX As Double = _FixedAssetsCardPlanRows_Last.BruttoHUFBallance * _FixedAssetsCard.FixedAssetsCardPlanRows(0).KeyTax / 100 / 12
Dim _StartDate As Date = _FixedAssetsCardPlanRows_Last.DateFrom
Dim _EndDate As New Date(Now.Year, 12, 31)
Dim _RowIndex As Long = _FixedAssetsCardPlanRows_Last.RowIndex
Dim _ActYear As Date = New Date(_StartDate.Year, _StartDate.Month, 1)
Dim _DateFrom As Date = _StartDate
Dim _DateTo As Date = New Date(_ActYear.Year, _ActYear.Month + 1, 1).AddDays(-1)
Do
Dim _FixedAssetsCardPlanRows As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _RowIndex
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.DateFrom = _DateFrom
.DateTo = _DateTo
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.KeyACC = _FixedAssetsCardPlanRows_Last.KeyACC
.KeyTax = _FixedAssetsCardPlanRows_Last.KeyTax
.SalvageHUF = _FixedAssetsCardPlanRows_Last.SalvageHUF
End With
_RowIndex += 1
_ActYear = _DateTo
_DateFrom = _DateTo.AddDays(1)
_DateTo = (New Date(_DateFrom.Year, _DateFrom.Month, 1).AddMonths(1)).AddDays(-1)
_FixedAssetsCardPlanRows_Collection_NEW.Add(_FixedAssetsCardPlanRows)
Loop While _EndDate >= _ActYear
Dim _NettoHUFBallanceACC As Double = _FixedAssetsCardPlanRows_Last.NettoHUFBallanceACC + _FixedAssetsCardPlanRows_Last.DecrepationHUFACC
Dim _NettoHUFBallanceTAX As Double = _FixedAssetsCardPlanRows_Last.NettoHUFBallanceTAX + _FixedAssetsCardPlanRows_Last.DecrepationHUFTAX
Dim _BruttoHUFBallance As Double = _FixedAssetsCardPlanRows_Last.BruttoHUFBallance
For ik = 0 To _FixedAssetsCardPlanRows_Collection_NEW.Count - 1
Dim _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(ik), FixedAssetsCardPlanRows)
With _FixedAssetsCardPlanRows
Dim _ActMounthDayCount As Long = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActMounthDayCount, 0, MidpointRounding.AwayFromZero)
.DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActMounthDayCount, 0, MidpointRounding.AwayFromZero)
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
If _NettoHUFBallanceACC <> 0 Then
If _NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
_NettoHUFBallanceACC = 0
.DayCountACC = Math.Round(.DecrepationHUFACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _NettoHUFBallanceACC - .DecrepationHUFACC
End If
Else
.NettoHUFBallanceACC = .SalvageHUF
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.DayCountACC = 0
End If
If _NettoHUFBallanceTAX <> 0 Then
If _NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
_NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.DecrepationHUFTAX / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
Else
.NettoHUFBallanceTAX = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.DayCountTAX = 0
End If
.BruttoHUF = 0
.BruttoHUFBallance = _BruttoHUFBallance
End With
If _FixedAssetsCardPlanRows.NettoHUFBallanceACC <> 0 And _NettoHUFBallanceACC <> 0 Then
_NettoHUFBallanceACC = _FixedAssetsCardPlanRows.NettoHUFBallanceACC
End If
If _FixedAssetsCardPlanRows.NettoHUFBallanceTAX <> 0 Then
_NettoHUFBallanceTAX = _FixedAssetsCardPlanRows.NettoHUFBallanceTAX
End If
_BruttoHUFBallance = _FixedAssetsCardPlanRows.BruttoHUFBallance
Next
Case eFixedAssetsPeriod.eQuarter
Dim _FixedAssetsCardPlanRows_Last As FixedAssetsCardPlanRows = _FixedAssetsCard.FixedAssetsCardPlanRows(_FixedAssetsCard.FixedAssetsCardPlanRows.Count - 2)
Dim _FixedAssetsCardPlanRows_Collection_NEW As New ArrayList
Dim _DecrepationPeriodAmountACC As Double = _FixedAssetsCardPlanRows_Last.BruttoHUFBallance * _FixedAssetsCard.FixedAssetsCardPlanRows(0).KeyACC / 100 / 4
Dim _DecrepationPeriodAmountTAX As Double = _FixedAssetsCardPlanRows_Last.BruttoHUFBallance * _FixedAssetsCard.FixedAssetsCardPlanRows(0).KeyTax / 100 / 4
Dim _StartDate As Date = _FixedAssetsCardPlanRows_Last.DateFrom
Dim _EndDate As New Date(Now.Year, 12, 31)
Dim _RowIndex As Long = _FixedAssetsCardPlanRows_Last.RowIndex
Dim _ActYear As Date = New Date(_StartDate.Year, _StartDate.Month, 1)
Dim _DateFrom As Date = _StartDate
Dim _DateTo As Date = (New Date(_ActYear.Year, _ActYear.Month, 1).AddMonths(3)).AddDays(-1)
Do
Dim _FixedAssetsCardPlanRows As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _RowIndex
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.DateFrom = _DateFrom
.DateTo = _DateTo
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.KeyACC = _FixedAssetsCardPlanRows_Last.KeyACC
.KeyTax = _FixedAssetsCardPlanRows_Last.KeyTax
.SalvageHUF = _FixedAssetsCardPlanRows_Last.SalvageHUF
End With
_RowIndex += 1
_ActYear = _DateTo
_DateFrom = _DateTo.AddDays(1)
_DateTo = (New Date(_DateFrom.Year, _DateFrom.Month, 1).AddMonths(3)).AddDays(-1)
_FixedAssetsCardPlanRows_Collection_NEW.Add(_FixedAssetsCardPlanRows)
Loop While _EndDate >= _ActYear
Dim _NettoHUFBallanceACC As Double = _FixedAssetsCardPlanRows_Last.NettoHUFBallanceACC + _FixedAssetsCardPlanRows_Last.DecrepationHUFACC
Dim _NettoHUFBallanceTAX As Double = _FixedAssetsCardPlanRows_Last.NettoHUFBallanceTAX + _FixedAssetsCardPlanRows_Last.DecrepationHUFTAX
Dim _BruttoHUFBallance As Double = _FixedAssetsCardPlanRows_Last.BruttoHUFBallance
For ik = 0 To _FixedAssetsCardPlanRows_Collection_NEW.Count - 1
Dim _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(ik), FixedAssetsCardPlanRows)
With _FixedAssetsCardPlanRows
Dim _ActQuarterDayCount As Long = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActQuarterDayCount, 0, MidpointRounding.AwayFromZero)
.DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActQuarterDayCount, 0, MidpointRounding.AwayFromZero)
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
If _NettoHUFBallanceACC <> 0 Then
If _NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
_NettoHUFBallanceACC = 0
.DayCountACC = Math.Round(.DecrepationHUFACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _NettoHUFBallanceACC - .DecrepationHUFACC
End If
Else
.NettoHUFBallanceACC = .SalvageHUF
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.DayCountACC = 0
End If
If _NettoHUFBallanceTAX <> 0 Then
If _NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
_NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.DecrepationHUFTAX / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
Else
.NettoHUFBallanceTAX = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.DayCountTAX = 0
End If
.BruttoHUF = 0
.BruttoHUFBallance = _BruttoHUFBallance
End With
If _FixedAssetsCardPlanRows.NettoHUFBallanceACC <> 0 And _NettoHUFBallanceACC <> 0 Then
_NettoHUFBallanceACC = _FixedAssetsCardPlanRows.NettoHUFBallanceACC
End If
If _FixedAssetsCardPlanRows.NettoHUFBallanceTAX <> 0 Then
_NettoHUFBallanceTAX = _FixedAssetsCardPlanRows.NettoHUFBallanceTAX
End If
_BruttoHUFBallance = _FixedAssetsCardPlanRows.BruttoHUFBallance
Next
Case eFixedAssetsPeriod.eYear
Dim _FixedAssetsCardPlanRows_Last As FixedAssetsCardPlanRows = _FixedAssetsCard.FixedAssetsCardPlanRows(_FixedAssetsCard.FixedAssetsCardPlanRows.Count - 2)
Dim _StartDate As Date = _FixedAssetsCardPlanRows_Last.DateFrom
Dim _EndDate As New Date(Now.Year, 12, 31)
Dim _FullDayCount As Long = DateDiff(DateInterval.Day, _StartDate, _EndDate)
Dim _RowIndex As Long = _FixedAssetsCardPlanRows_Last.RowIndex
Dim _DecrepationPeriodAmountACC As Double = _FixedAssetsCardPlanRows_Last.BruttoHUFBallance * _FixedAssetsCard.FixedAssetsCardPlanRows(0).KeyACC / 100
Dim _DecrepationPeriodAmountTAX As Double = _FixedAssetsCardPlanRows_Last.BruttoHUFBallance * _FixedAssetsCard.FixedAssetsCardPlanRows(0).KeyTax / 100
Dim _ActYear As Long = _StartDate.Year
Dim _DateFrom As Date = _StartDate
Dim _DateTo As Date = New Date(_ActYear + 1, 1, 1).AddDays(-1)
Dim _FixedAssetsCardPlanRows_Collection_NEW As New ArrayList
Do
Dim _FixedAssetsCardPlanRows As New FixedAssetsCardPlanRows(_ocur.Session)
With _FixedAssetsCardPlanRows
.FixedAssetsCard = _FixedAssetsCard
.RowIndex = _RowIndex
.FixedAssetsCardPlanRowsType = eFixedAssetsCardPlanRowsType.eNormal
.DateFrom = _DateFrom
.DateTo = _DateTo
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo) + 1
.KeyACC = _FixedAssetsCard.FixedAssetsCardPlanRows(0).KeyACC
.KeyTax = _FixedAssetsCard.FixedAssetsCardPlanRows(0).KeyTax
.SalvageHUF = _FixedAssetsCardPlanRows_Last.SalvageHUF
End With
_RowIndex += 1
_ActYear += 1
_DateFrom = _DateTo.AddDays(1)
_DateTo = New Date(_DateFrom.Year + 1, 1, 1).AddDays(-1)
_FixedAssetsCardPlanRows_Collection_NEW.Add(_FixedAssetsCardPlanRows)
Loop While Now.Year >= _ActYear
Dim _NettoHUFBallanceACC As Double = _FixedAssetsCardPlanRows_Last.NettoHUFBallanceACC + _FixedAssetsCardPlanRows_Last.DecrepationHUFACC
Dim _NettoHUFBallanceTAX As Double = _FixedAssetsCardPlanRows_Last.NettoHUFBallanceTAX + _FixedAssetsCardPlanRows_Last.DecrepationHUFTAX
Dim _BruttoHUFBallance As Double = _FixedAssetsCardPlanRows_Last.BruttoHUFBallance
For ik = 0 To _FixedAssetsCardPlanRows_Collection_NEW.Count - 1
Dim _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_Collection_NEW(ik), FixedAssetsCardPlanRows)
With _FixedAssetsCardPlanRows
Dim _ActYearDayCount As Long = DateDiff(DateInterval.Day, New Date(.DateFrom.Year, 1, 1), New Date(.DateFrom.Year, 12, 31))
.DecrepationHUFACC = Math.Round(_DecrepationPeriodAmountACC * .DayCountACC / _ActYearDayCount, 0, MidpointRounding.AwayFromZero)
.DecrepationHUFTAX = Math.Round(_DecrepationPeriodAmountTAX * .DayCountTAX / _ActYearDayCount, 0, MidpointRounding.AwayFromZero)
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
If _NettoHUFBallanceACC <> 0 Then
If _NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
_NettoHUFBallanceACC = 0
.DayCountACC = Math.Round(.NettoHUFBallanceACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _NettoHUFBallanceACC - .DecrepationHUFACC
End If
Else
.NettoHUFBallanceACC = .SalvageHUF
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.DayCountACC = 0
End If
If _NettoHUFBallanceTAX <> 0 Then
If _NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
_NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.NettoHUFBallanceACC / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
Else
.NettoHUFBallanceTAX = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.DayCountTAX = 0
End If
.BruttoHUF = 0
.BruttoHUFBallance = _BruttoHUFBallance
End With
If _FixedAssetsCardPlanRows.NettoHUFBallanceACC <> 0 And _NettoHUFBallanceACC <> 0 Then
_NettoHUFBallanceACC = _FixedAssetsCardPlanRows.NettoHUFBallanceACC
End If
If _FixedAssetsCardPlanRows.NettoHUFBallanceTAX <> 0 Then
_NettoHUFBallanceTAX = _FixedAssetsCardPlanRows.NettoHUFBallanceTAX
End If
_BruttoHUFBallance = _FixedAssetsCardPlanRows.BruttoHUFBallance
Next
End Select
_FixedAssetsCardPlanRows_Collection_DEL.Add(_FixedAssetsCard.FixedAssetsCardPlanRows(_FixedAssetsCard.FixedAssetsCardPlanRows.Count - 1))
_FixedAssetsCardPlanRows_Collection_DEL.Add(_FixedAssetsCard.FixedAssetsCardPlanRows(_FixedAssetsCard.FixedAssetsCardPlanRows.Count - 2))
_ocur.Delete(_FixedAssetsCardPlanRows_Collection_DEL)
_ocur.CommitChanges()
End Sub
Private Sub RegenerateReceivedFromAnotherSystem(_ocur As Xpo.XPObjectSpace, _FixedAssetsCard As FixedAssetsCard)
Dim _FixedAssetsCardPlanRows_Collection As New XPCollection(Of FixedAssetsCardPlanRows)(_ocur.Session, CriteriaOperator.Parse("FixedAssetsCard=?", _FixedAssetsCard))
_FixedAssetsCardPlanRows_Collection.Sorting.Add(New SortProperty("RowIndex", DB.SortingDirection.Ascending))
_FixedAssetsCardPlanRows_Collection(0).IsModified = True
Dim _FixedAssetsCardPlanRows_DEL_Collection As New ArrayList
Dim _FixedAssetsCardPlanRows_NEW_Collection As New ArrayList
Dim _LastDate As Date = _FixedAssetsCard.DateOpen.AddDays(-1)
For Each _FixedAssetsCardPlanRows As FixedAssetsCardPlanRows In _FixedAssetsCardPlanRows_Collection
If _FixedAssetsCardPlanRows.FixedAssetsCardPlanRowsType <> eFixedAssetsCardPlanRowsType.eActivated Then
If _FixedAssetsCardPlanRows.DateTo >= _LastDate Then
_FixedAssetsCardPlanRows_NEW_Collection.Add(_FixedAssetsCardPlanRows)
Else
_FixedAssetsCardPlanRows_DEL_Collection.Add(_FixedAssetsCardPlanRows)
End If
End If
Next
Dim _FixedAssetsCardPlanRows_First As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_NEW_Collection(0), FixedAssetsCardPlanRows)
With _FixedAssetsCardPlanRows_First
.DateFrom = _FixedAssetsCard.DateActivation
.DayCountACC = DateDiff(DateInterval.Day, .DateFrom, .DateTo)
.DayCountTAX = DateDiff(DateInterval.Day, .DateFrom, .DateTo)
.NettoHUFBallanceACC = _FixedAssetsCard.AmountHUFOpen
.NettoHUFBallanceTAX = _FixedAssetsCard.AmountHUFOpen
.DecrepationHUFACC = _FixedAssetsCard.AmountHUFBrutto - _FixedAssetsCard.AmountHUFOpen
.DecrepationHUFTAX = _FixedAssetsCard.AmountHUFBrutto - _FixedAssetsCard.AmountHUFOpen
.DayDecrepationACC = Math.Round(.DecrepationHUFACC / .DayCountACC, 2, MidpointRounding.AwayFromZero)
.DayDecrepationTAX = Math.Round(.DecrepationHUFTAX / .DayCountTAX, 2, MidpointRounding.AwayFromZero)
.RowIndex = 2
.IsModified = True
End With
Dim _ActRowIndex As Long = _FixedAssetsCardPlanRows_First.RowIndex
Dim _NettoHUFBallanceACC As Double = _FixedAssetsCardPlanRows_First.NettoHUFBallanceACC
Dim _NettoHUFBallanceTAX As Double = _FixedAssetsCardPlanRows_First.NettoHUFBallanceTAX
For ik = 1 To _FixedAssetsCardPlanRows_NEW_Collection.Count - 1
Dim _FixedAssetsCardPlanRows_Act As FixedAssetsCardPlanRows = TryCast(_FixedAssetsCardPlanRows_NEW_Collection(ik), FixedAssetsCardPlanRows)
With _FixedAssetsCardPlanRows_Act
.RowIndex = ik + 2
If _NettoHUFBallanceACC <> 0 Then
If _NettoHUFBallanceACC - .DecrepationHUFACC <= .SalvageHUF Then
.DecrepationHUFACC = _NettoHUFBallanceACC - .SalvageHUF
.NettoHUFBallanceACC = .SalvageHUF
_NettoHUFBallanceACC = 0
.DayCountACC = Math.Round(.DecrepationHUFACC / .DayDecrepationACC, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceACC = _NettoHUFBallanceACC - .DecrepationHUFACC
End If
Else
.NettoHUFBallanceACC = .SalvageHUF
.DayDecrepationACC = 0
.DecrepationHUFACC = 0
.DayCountACC = 0
End If
If _NettoHUFBallanceTAX <> 0 Then
If _NettoHUFBallanceTAX - .DecrepationHUFTAX <= 0 Then
.DecrepationHUFTAX = _NettoHUFBallanceTAX
.NettoHUFBallanceTAX = 0
_NettoHUFBallanceTAX = 0
.DayCountTAX = Math.Round(.DecrepationHUFTAX / .DayDecrepationTAX, 0, MidpointRounding.AwayFromZero)
Else
.NettoHUFBallanceTAX = _NettoHUFBallanceTAX - .DecrepationHUFTAX
End If
Else
.NettoHUFBallanceTAX = 0
.DayDecrepationTAX = 0
.DecrepationHUFTAX = 0
.DayCountTAX = 0
End If
End With
If _FixedAssetsCardPlanRows_Act.NettoHUFBallanceACC <> 0 And _NettoHUFBallanceACC <> 0 Then
_NettoHUFBallanceACC = _FixedAssetsCardPlanRows_Act.NettoHUFBallanceACC
End If
If _FixedAssetsCardPlanRows_Act.NettoHUFBallanceTAX <> 0 Then
_NettoHUFBallanceTAX = _FixedAssetsCardPlanRows_Act.NettoHUFBallanceTAX
End If
Next
_ocur.Delete(_FixedAssetsCardPlanRows_DEL_Collection)
_ocur.CommitChanges()
End Sub
Private Sub FixedAssetsCard_OpenYear_PopUp_AcceptAction_Executing(sender As Object, e As CancelEventArgs)
Dim _ActYear As Long = GetSQLTime(TryCast(View.ObjectSpace, Xpo.XPObjectSpace).Session).Year
Dim _FixedAssetsCard_OpenYear_PopUp As FixedAssetsCard_OpenYear_PopUp = TryCast(View.SelectedObjects(0), FixedAssetsCard_OpenYear_PopUp)
If _FixedAssetsCard_OpenYear_PopUp IsNot Nothing Then
If _FixedAssetsCard_OpenYear_PopUp.TargetYear <= _ActYear Then e.Cancel = True
End If
End Sub
#End Region
End Class