AccountingDocumentBaseHandlers.cs
5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using System;
using System.Collections.Generic;
using System.Linq;
using Sungero.Core;
using Sungero.CoreEntities;
using Sungero.Docflow.AccountingDocumentBase;
namespace Sungero.Docflow
{
partial class AccountingDocumentBaseClientHandlers
{
public virtual void DateValueInput(Sungero.Presentation.DateTimeValueInputEventArgs e)
{
if (e.NewValue != null && e.NewValue < Calendar.SqlMinValue)
e.AddError(_obj.Info.Properties.Date, Sungero.Docflow.OfficialDocuments.Resources.SetCorrectDate);
}
public virtual void CounterpartyValueInput(Sungero.Docflow.Client.AccountingDocumentBaseCounterpartyValueInputEventArgs e)
{
this._obj.State.Properties.Counterparty.HighlightColor = Sungero.Core.Colors.Empty;
}
public override void BusinessUnitValueInput(Sungero.Docflow.Client.OfficialDocumentBusinessUnitValueInputEventArgs e)
{
base.BusinessUnitValueInput(e);
this._obj.State.Properties.BusinessUnit.HighlightColor = Sungero.Core.Colors.Empty;
}
public virtual void CurrencyValueInput(Sungero.Docflow.Client.AccountingDocumentBaseCurrencyValueInputEventArgs e)
{
this._obj.State.Properties.Currency.HighlightColor = Sungero.Core.Colors.Empty;
}
public override void Closing(Sungero.Presentation.FormClosingEventArgs e)
{
base.Closing(e);
_obj.State.Properties.Counterparty.IsRequired = false;
}
public override void DocumentKindValueInput(Sungero.Docflow.Client.OfficialDocumentDocumentKindValueInputEventArgs e)
{
base.DocumentKindValueInput(e);
if (e.NewValue != e.OldValue && e.NewValue != null)
{
if (_obj.BusinessUnit != null && _obj.Department != null && _obj.DocumentRegister != null)
{
Enumeration settingType;
if (e.NewValue.NumberingType == Docflow.DocumentKind.NumberingType.Numerable)
settingType = Docflow.RegistrationSetting.SettingType.Numeration;
else
settingType = _obj.RegistrationState == RegistrationState.Registered ?
Docflow.RegistrationSetting.SettingType.Registration :
Docflow.RegistrationSetting.SettingType.Reservation;
var hasRegistrationSetting = Functions.RegistrationSetting.GetAvailableSettingsByParams(settingType, _obj.BusinessUnit, e.NewValue, _obj.Department)
.Any(s => Equals(s.DocumentRegister, _obj.DocumentRegister));
if (!hasRegistrationSetting)
e.AddError(AccountingDocumentBases.Resources.NeedCancelRegistrationToChangeKind);
}
}
}
public override void Showing(Sungero.Presentation.FormShowingEventArgs e)
{
base.Showing(e);
if (_obj.IsFormalized == true)
{
e.HideAction(_obj.Info.Actions.OpenOriginal);
e.HideAction(_obj.Info.Actions.CreateDocumentFromVersion);
}
}
public override void Refresh(Sungero.Presentation.FormRefreshEventArgs e)
{
base.Refresh(e);
if (_obj.ExchangeState == OfficialDocument.ExchangeState.SignRequired && _obj.BuyerTitleId == null &&
!FinancialArchive.IncomingTaxInvoices.Is(_obj))
e.AddInformation(Sungero.Docflow.AccountingDocumentBases.Resources.FillBuyerInfoAwaited, AccountingDocumentBases.Info.Actions.FillBuyerInfo);
if (!_obj.State.IsInserted && _obj.IsFormalizedSignatoryEmpty == true)
e.AddInformation(Sungero.Docflow.AccountingDocumentBases.Resources.FillSellerInfoAwaited, AccountingDocumentBases.Info.Actions.FillSellerInfo);
var isCompany = Sungero.Parties.CompanyBases.Is(_obj.Counterparty) || _obj.Counterparty == null;
_obj.State.Properties.Contact.IsEnabled = isCompany;
_obj.State.Properties.CounterpartySignatory.IsEnabled = isCompany;
}
public override void ShowingSignDialog(Sungero.Domain.Client.ShowingSignDialogEventArgs e)
{
base.ShowingSignDialog(e);
if (e.CanApprove)
{
try
{
Functions.AccountingDocumentBase.GenerateDefaultSellerTitle(_obj);
}
catch (AppliedCodeException ex)
{
e.CanApprove = false;
e.Hint.Add(ex.Message);
}
catch (Exception ex)
{
e.CanApprove = false;
Logger.ErrorFormat("Error generation default seller title: ", ex);
e.Hint.Add(Sungero.Docflow.AccountingDocumentBases.Resources.ErrorSellerTitlePropertiesFilling);
}
try
{
Functions.AccountingDocumentBase.GenerateDefaultBuyerTitle(_obj);
}
catch (AppliedCodeException ex)
{
e.CanApprove = false;
e.Hint.Add(ex.Message);
}
catch (Exception ex)
{
e.CanApprove = false;
Logger.ErrorFormat("Error generation default buyer title: ", ex);
e.Hint.Add(Sungero.Docflow.AccountingDocumentBases.Resources.ErrorBuyerTitlePropertiesFilling);
}
}
}
public virtual void IsAdjustmentValueInput(Sungero.Presentation.BooleanValueInputEventArgs e)
{
_obj.State.Properties.Corrected.IsEnabled = e.NewValue == true;
}
public virtual void TotalAmountValueInput(Sungero.Presentation.DoubleValueInputEventArgs e)
{
if (e.NewValue <= 0)
e.AddError(Contracts.ContractualDocuments.Resources.TotalAmountMustBePositive);
this._obj.State.Properties.TotalAmount.HighlightColor = Sungero.Core.Colors.Empty;
}
}
}