Files
Nuvolar/Nuvolar.Module/BusinessObjects/Business/BusinessTransactions/Invoice/InvoiceCreditNote/InvoiceCreditNoteHeader.vb
T
2018-07-26 09:16:10 +02:00

195 lines
7.3 KiB
VB.net

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
'CreditNoteRows
<DefaultClassOptions()>
<NavigationItem(False)>
<CreatableItem(False)>
<Appearance("InvoiceCreditNoteHeader - Disable UserCreated all time", AppearanceItemType.ViewItem, "1=1", TargetItems:="UserCreated", Enabled:=False)>
<Appearance("InvoiceCreditNoteHeader - Disable ObjectCreated all time", AppearanceItemType.ViewItem, "1=1", TargetItems:="ObjectCreated", Enabled:=False)>
<Appearance("InvoiceCreditNoteHeader - Disable CustomersFrom when not empty", AppearanceItemType.ViewItem, "IsNull(CustomersFrom)=False", TargetItems:="CustomersFrom", Enabled:=False)>
<Appearance("InvoiceCreditNoteHeader - Disable Customers when not empty", AppearanceItemType.ViewItem, "IsNull(Customers)=False", TargetItems:="Customers", Enabled:=False)>
<Appearance("InvoiceCreditNoteHeader - Hide Item2 when IsNewObject", AppearanceItemType.LayoutItem, "IsNull(ObjectCreated) Or IsNull(UserCreated)", TargetItems:="Item2", Visibility:=Editors.ViewItemVisibility.Hide)>
Public Class InvoiceCreditNoteHeader
Inherits BaseObject
Private _CustomersFrom As CustomersFrom
Private _Customers As Customers
Private _Storage As Storage
Private _StorageMoveType As StorageMoveType
Private _DateExecution As Date
Private _ObjectCreated As Date
Private _UserCreated As User
Private _PaymentOption As PaymentOption
Private _DatePayment As Date
Private _Description As String
Private _CurrencyRate As Double
Private _CurrencyName As CurrencyName
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
Public Overrides Sub AfterConstruction()
MyBase.AfterConstruction()
'DateExecution = GetSQLTime(Session)
CurrencyRate = 1
End Sub
Protected Overrides Sub OnSaving()
MyBase.OnSaving()
If Session.IsNewObject(Me) Then
ObjectCreated = GetSQLTime(Session)
UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser))
End If
End Sub
<RuleRequiredField("InvoiceCreditNoteHeader - CustomersFrom", DefaultContexts.Save)>
Property CustomersFrom As CustomersFrom
Get
Return _CustomersFrom
End Get
Set(value As CustomersFrom)
SetPropertyValue("CustomersFrom", _CustomersFrom, value)
End Set
End Property
<RuleRequiredField("InvoiceCreditNoteHeader - Customers", DefaultContexts.Save)>
Property Customers As Customers
Get
Return _Customers
End Get
Set(value As Customers)
SetPropertyValue("Customers", _Customers, value)
End Set
End Property
<RuleRequiredField("InvoiceCreditNoteHeader - Storage", DefaultContexts.Save)>
<DataSourceCriteria("IsActive != False")>
Property Storage As Storage
Get
Return _Storage
End Get
Set(value As Storage)
SetPropertyValue("Storage", _Storage, value)
End Set
End Property
<RuleRequiredField("InvoiceCreditNoteHeader-StorageMoveType", DefaultContexts.Save)>
<ImmediatePostData(True), DataSourceCriteria("Storage='@This.Storage' AND MoveType=8")>
Property StorageMoveType As StorageMoveType
Get
Return _StorageMoveType
End Get
Set(value As StorageMoveType)
SetPropertyValue("StorageMoveType", _StorageMoveType, value)
End Set
End Property
<RuleRequiredField("InvoiceCreditNoteHeader - DateExecution", DefaultContexts.Save)>
Property DateExecution As Date
Get
Return _DateExecution
End Get
Set(value As Date)
SetPropertyValue("DateExecution", _DateExecution, value)
If Session.IsObjectsLoading = False AndAlso Session.IsObjectsSaving = False Then
'// MNB árfolyam lekérése
Dim _CurrencyRate_Collection As XPCollection(Of CurrencyRate) = New XPCollection(Of CurrencyRate)(Session, CriteriaOperator.Parse("CurrencyName=? and IsMNB=True and GetDate(DateValid)<=?", CurrencyName, DateExecution.Date))
_CurrencyRate_Collection.Sorting.Add(New SortProperty("DateValid", DB.SortingDirection.Descending))
If _CurrencyRate_Collection.Count > 0 Then
For Each _CurrencyRateX In _CurrencyRate_Collection
If _CurrencyRateX.DateValid.Date = _DateExecution.Date Then
CurrencyRate = _CurrencyRateX.RateAverage
Exit For
End If
Exit For
Next
Else
Throw New Exception("*Nincs beállítva sem a pénzeszköz árfolyama sem az MNB árfolyama !")
End If
End If
End Set
End Property
Property ObjectCreated As Date
Get
Return _ObjectCreated
End Get
Set(value As Date)
SetPropertyValue("ObjectCreated", _ObjectCreated, value)
End Set
End Property
Property UserCreated As User
Get
Return _UserCreated
End Get
Set(value As User)
SetPropertyValue("UserCreated", _UserCreated, value)
End Set
End Property
<RuleRequiredField("InvoiceCreditNoteHeader - PaymentOption", DefaultContexts.Save)>
Property PaymentOption As PaymentOption
Get
Return _PaymentOption
End Get
Set(value As PaymentOption)
SetPropertyValue("PaymentOption", _PaymentOption, value)
End Set
End Property
<RuleRequiredField("InvoiceCreditNoteHeader - DatePayment", DefaultContexts.Save)>
Property DatePayment As Date
Get
Return _DatePayment
End Get
Set(value As Date)
SetPropertyValue("DatePayment", _DatePayment, value)
End Set
End Property
<Size(-1)>
Property Description As String
Get
Return _Description
End Get
Set(value As String)
SetPropertyValue("Description", _Description, value)
End Set
End Property
''' <summary>
''' Árfolyam, amivel számolja !!!
''' </summary>
''' <returns></returns>
Property CurrencyRate As Double
Get
Return _CurrencyRate
End Get
Set(value As Double)
SetPropertyValue("CurrencyRate", _CurrencyRate, value)
End Set
End Property
''' <summary>
''' DEVIZA
''' </summary>
''' <returns></returns>
Property CurrencyName As CurrencyName
Get
Return _CurrencyName
End Get
Set(value As CurrencyName)
SetPropertyValue("CurrencyName", _CurrencyName, value)
End Set
End Property
'--==ReadOnly==--
<VisibleInListView(False)>
<Association("InvoiceCreditNoteHeader-InvoiceCreditNoteRows", GetType(InvoiceCreditNoteRows))>
ReadOnly Property InvoiceCreditNoteRows As XPCollection(Of InvoiceCreditNoteRows)
Get
Return GetCollection(Of InvoiceCreditNoteRows)("InvoiceCreditNoteRows")
End Get
End Property
End Class