-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApplication.cs
More file actions
199 lines (150 loc) · 6.66 KB
/
Application.cs
File metadata and controls
199 lines (150 loc) · 6.66 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using System;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Unity.GrantManager.Assessments;
using Unity.GrantManager.GrantApplications;
using Unity.GrantManager.Identity;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
namespace Unity.GrantManager.Applications;
// NOTE: See https://learn.microsoft.com/en-us/ef/core/miscellaneous/nullable-reference-types#required-navigation-properties
public class Application : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
public Guid ApplicationFormId { get; set; }
public virtual ApplicationForm ApplicationForm
{
set => _applicationForm = value;
get => _applicationForm
?? throw new InvalidOperationException("Uninitialized property: " + nameof(Applicant));
}
private ApplicationForm? _applicationForm;
public Guid ApplicantId { get; set; }
public virtual Applicant Applicant
{
set => _applicant = value;
get => _applicant
?? throw new InvalidOperationException("Uninitialized property: " + nameof(Applicant));
}
private Applicant? _applicant;
public virtual ApplicantAgent? ApplicantAgent { get; set; }
public Guid ApplicationStatusId { get; set; }
public virtual ApplicationStatus ApplicationStatus
{
set => _applicationStatus = value;
get => _applicationStatus
?? throw new InvalidOperationException("Uninitialized property: " + nameof(ApplicationStatus));
}
private ApplicationStatus? _applicationStatus;
public virtual Collection<Assessment>? Assessments { get; set; }
public virtual Collection<ApplicationTags>? ApplicationTags { get; set; }
public virtual Collection<ApplicationAssignment>? ApplicationAssignments { get; set; }
public string ProjectName { get; set; } = string.Empty;
public string ReferenceNo { get; set; } = string.Empty;
public decimal RequestedAmount { get; set; }
public decimal TotalProjectBudget { get; set; }
public string? EconomicRegion { get; set; } = null;
public string? City { get; set; } = null;
public DateTime? ProposalDate { get; set; }
public DateTime SubmissionDate { get; set; }
public DateTime? AssessmentStartDate { get; set; }
public DateTime? FinalDecisionDate { get; set; }
public DateTime? DueDate { get; set; }
public DateTime? NotificationDate { get; set; }
[Column(TypeName = "jsonb")]
public string? Payload { get; set; }
public string? ProjectSummary { get; set; }
public int? TotalScore { get; set; } = null;
public decimal RecommendedAmount { get; set; } = 0;
public decimal ApprovedAmount { get; set; } = 0;
public string? LikelihoodOfFunding { get; set; }
public string? DueDiligenceStatus { get; set; }
public string? SubStatus { get; set; }
public string? DeclineRational { get; set; }
public string? Notes { get; set; }
public string? AssessmentResultStatus { get; set; }
public DateTime? AssessmentResultDate { get; set; }
public DateTime? ProjectStartDate { get; set; }
public DateTime? ProjectEndDate { get; set; }
public double? PercentageTotalProjectBudget { get; set; }
public decimal? ProjectFundingTotal { get; set; }
public string? Community { get; set; }
public int? CommunityPopulation { get; set; }
public string? Acquisition { get; set; }
public string? Forestry { get; set; }
public string? ForestryFocus { get; set; }
public string? ElectoralDistrict { get; set; }
public string? Place { get; set; }
public string? RegionalDistrict { get; set; }
public Guid? TenantId { get; set; }
public Guid? OwnerId { get; set; }
// Navigation Property - Application Status
public virtual Person? Owner { get; set; }
public string? SigningAuthorityFullName { get; set; }
public string? SigningAuthorityTitle { get; set; }
public string? SigningAuthorityEmail { get; set; }
public string? SigningAuthorityBusinessPhone { get; set; }
public string? SigningAuthorityCellPhone { get; set; }
public string? ContractNumber { get; set; }
public DateTime? ContractExecutionDate { get; set; }
public string? RiskRanking { get; set; }
public bool IsInFinalDecisionState()
{
return GrantApplicationStateGroups.FinalDecisionStates.Contains(ApplicationStatus.StatusCode);
}
public void UpdateAlwaysChangeableFields(string? notes, string? subStatus, string? likelihoodOfFunding, decimal? totalProjectBudget, DateTime? notificationDate, string? riskRanking)
{
Notes = notes;
SubStatus = subStatus;
LikelihoodOfFunding = likelihoodOfFunding;
TotalProjectBudget = totalProjectBudget ?? 0;
NotificationDate = notificationDate;
RiskRanking = riskRanking;
}
public void UpdateApprovalFieldsRequiringPostEditPermission(decimal? approvedAmount)
{
ApprovedAmount = approvedAmount ?? 0;
}
public void UpdateAssessmentResultFieldsRequiringPostEditPermission(decimal? requestedAmount, int? totalScore)
{
RequestedAmount = requestedAmount ?? 0;
TotalScore = totalScore ?? 0;
}
public void UpdateAssessmentResultStatus(string? assessmentResultStatus)
{
if (assessmentResultStatus != AssessmentResultStatus)
{
AssessmentResultDate = DateTime.UtcNow;
}
AssessmentResultStatus = assessmentResultStatus;
}
public void UpdateFieldsOnlyForPreFinalDecision(string? dueDiligenceStatus, decimal? recommendedAmount, string? declineRational)
{
DueDiligenceStatus = dueDiligenceStatus;
RecommendedAmount = recommendedAmount ?? 0;
DeclineRational = declineRational;
}
public void ValidateAndChangeDueDate(DateTime? dueDate)
{
if ((DueDate != dueDate) && dueDate != null && dueDate.Value < DateTime.Now.AddDays(-1))
{
throw new BusinessException("Due Date cannot be a past date.");
}
else
{
DueDate = dueDate;
}
}
public void ValidateAndChangeFinalDecisionDate(DateTime? finalDecisionDate)
{
if ((FinalDecisionDate != finalDecisionDate) && finalDecisionDate != null && finalDecisionDate.Value > DateTime.Now)
{
throw new BusinessException("Decision Date cannot not be a future date.");
}
else
{
FinalDecisionDate = finalDecisionDate;
}
}
}