Skip to content

Commit

Permalink
S26 update funding version for supp and expense (#252)
Browse files Browse the repository at this point in the history
* Updated Dev

* Add Funding Version Field on Supp and Expense Application
  • Loading branch information
yiyiwang-cgi authored Oct 24, 2024
1 parent ee6fa07 commit 2538912
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 30 deletions.
94 changes: 94 additions & 0 deletions ECC.Core.DataContext/Entities/Entities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6205,6 +6205,38 @@ public string ofm_on_k12_school_grounds_or_board_affiliatedname
}
}

[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ofm_on_k12_school_grounds_or_board_affiliated")]
public virtual ecc_ynempty? ofm_on_k12_school_grounds_or_board_affiliated
{
[System.Diagnostics.DebuggerNonUserCode()]
get
{
return ((ecc_ynempty?)(EntityOptionSetEnum.GetEnum(this, "ofm_on_k12_school_grounds_or_board_affiliated")));
}
[System.Diagnostics.DebuggerNonUserCode()]
set
{
this.SetAttributeValue("ofm_on_k12_school_grounds_or_board_affiliated", value.HasValue ? new Microsoft.Xrm.Sdk.OptionSetValue((int)value) : null);
}
}

[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ofm_on_k12_school_grounds_or_board_affiliatedname")]
public string ofm_on_k12_school_grounds_or_board_affiliatedname
{
[System.Diagnostics.DebuggerNonUserCode()]
get
{
if (this.FormattedValues.Contains("ofm_on_k12_school_grounds_or_board_affiliated"))
{
return this.FormattedValues["ofm_on_k12_school_grounds_or_board_affiliated"];
}
else
{
return default(string);
}
}
}

[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ofm_on_reserve")]
public virtual ecc_ynempty? ofm_on_reserve
{
Expand Down Expand Up @@ -24945,6 +24977,21 @@ public virtual ecc_ynempty? ofm_accb_participation
}
}

[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ofm_accb_participation")]
public virtual ecc_ynempty? ofm_accb_participation
{
[System.Diagnostics.DebuggerNonUserCode()]
get
{
return ((ecc_ynempty?)(EntityOptionSetEnum.GetEnum(this, "ofm_accb_participation")));
}
[System.Diagnostics.DebuggerNonUserCode()]
set
{
this.SetAttributeValue("ofm_accb_participation", value.HasValue ? new Microsoft.Xrm.Sdk.OptionSetValue((int)value) : null);
}
}

[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ofm_accb_participationname")]
public string ofm_accb_participationname
{
Expand Down Expand Up @@ -26411,6 +26458,53 @@ public virtual ecc_ynempty? ofm_provide_previous_fy_financial_statements
}
}

[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ofm_provide_actual_expenses")]
public virtual ecc_ynempty? ofm_provide_actual_expenses
{
[System.Diagnostics.DebuggerNonUserCode()]
get
{
return ((ecc_ynempty?)(EntityOptionSetEnum.GetEnum(this, "ofm_provide_actual_expenses")));
}
[System.Diagnostics.DebuggerNonUserCode()]
set
{
this.SetAttributeValue("ofm_provide_actual_expenses", value.HasValue ? new Microsoft.Xrm.Sdk.OptionSetValue((int)value) : null);
}
}

[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ofm_provide_actual_expensesname")]
public string ofm_provide_actual_expensesname
{
[System.Diagnostics.DebuggerNonUserCode()]
get
{
if (this.FormattedValues.Contains("ofm_provide_actual_expenses"))
{
return this.FormattedValues["ofm_provide_actual_expenses"];
}
else
{
return default(string);
}
}
}

[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ofm_provide_previous_fy_financial_statements")]
public virtual ecc_ynempty? ofm_provide_previous_fy_financial_statements
{
[System.Diagnostics.DebuggerNonUserCode()]
get
{
return ((ecc_ynempty?)(EntityOptionSetEnum.GetEnum(this, "ofm_provide_previous_fy_financial_statements")));
}
[System.Diagnostics.DebuggerNonUserCode()]
set
{
this.SetAttributeValue("ofm_provide_previous_fy_financial_statements", value.HasValue ? new Microsoft.Xrm.Sdk.OptionSetValue((int)value) : null);
}
}

[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("ofm_provide_previous_fy_financial_statementsname")]
public string ofm_provide_previous_fy_financial_statementsname
{
Expand Down
32 changes: 32 additions & 0 deletions ECC.Core.DataContext/OptionSets/OptionSets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15642,6 +15642,38 @@ public enum ofm_system_message_StatusCode
Inactive = 2,
}

/// <summary>
/// Status of the OFM System Message
/// </summary>
[System.Runtime.Serialization.DataContractAttribute()]
public enum ofm_system_message_statecode
{

[System.Runtime.Serialization.EnumMemberAttribute()]
[OptionSetMetadataAttribute("Active", 0)]
Active = 0,

[System.Runtime.Serialization.EnumMemberAttribute()]
[OptionSetMetadataAttribute("Inactive", 1)]
Inactive = 1,
}

/// <summary>
/// Reason for the status of the OFM System Message
/// </summary>
[System.Runtime.Serialization.DataContractAttribute()]
public enum ofm_system_message_StatusCode
{

[System.Runtime.Serialization.EnumMemberAttribute()]
[OptionSetMetadataAttribute("Active", 0)]
Active = 1,

[System.Runtime.Serialization.EnumMemberAttribute()]
[OptionSetMetadataAttribute("Inactive", 1)]
Inactive = 2,
}

[System.Runtime.Serialization.DataContractAttribute()]
public enum ofm_verification_checklist_status
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ protected override void Execute(CodeActivityContext executionContext)

//generate the application funding number Base
tracingService.Trace("***Update Funding Number Base" + ofmFundingNumberBase);
Entity newudpate = new Entity();
newudpate.LogicalName = entity.LogicalName;
newudpate["ofm_applicationid"] = entity["ofm_applicationid"];
newudpate["ofm_funding_number_base"] = ofmFundingNumberBase;
service.Update(newudpate);
Entity newupdate = new Entity();
newupdate.LogicalName = entity.LogicalName;
newupdate["ofm_applicationid"] = entity["ofm_applicationid"];
newupdate["ofm_funding_number_base"] = ofmFundingNumberBase;
newupdate["ofm_funding_version_number"] = 0;
service.Update(newupdate);

// Create first Funding record
Entity newFundingRecord = new Entity("ofm_funding");
Expand All @@ -120,37 +121,42 @@ protected override void Execute(CodeActivityContext executionContext)
tracingService.Trace("\nStart resubmit logic implement, logical name: {0}, id:{1}", entity.LogicalName, entity.Id);
var fetchData = new
{
ofm_application = recordId.ToString(),
statecode = "0"
ofm_application = recordId.ToString()
};
fetchXml = $@"<?xml version=""1.0"" encoding=""utf-16""?>
<fetch>
<entity name=""ofm_funding"">
<attribute name=""ofm_application"" />
<attribute name=""statecode"" />
<attribute name=""statuscode"" />
<attribute name=""ofm_version_number"" />
<entity name=""ofm_application"">
<attribute name=""ofm_funding_number_base"" />
<attribute name=""ofm_funding_version_number"" />
<filter>
<condition attribute=""ofm_application"" operator=""eq"" value=""{fetchData.ofm_application}"" />
<condition attribute=""statecode"" operator=""eq"" value=""{fetchData.statecode}"" />
<condition attribute=""ofm_applicationid"" operator=""eq"" value=""{fetchData.ofm_application}"" />
</filter>
<order attribute=""ofm_version_number"" descending=""true"" />
</entity>
</fetch>";

EntityCollection fundingRecords = service.RetrieveMultiple(new FetchExpression(fetchXml));
if (fundingRecords.Entities.Count > 0 && fundingRecords[0] != null)
EntityCollection applicationRecord = service.RetrieveMultiple(new FetchExpression(fetchXml));
tracingService.Trace("application count: " + applicationRecord.Entities.Count);
if (applicationRecord.Entities.Count > 0 && applicationRecord[0] != null)
{
var id = fundingRecords[0].Id;
tracingService.Trace("\nResubmission, create new funding records:" + id);
tracingService.Trace("\nModification, create new funding records, current version: " + applicationRecord[0].GetAttributeValue<int>("ofm_funding_version_number"));
Entity newFundingRecord = new Entity("ofm_funding");
newFundingRecord["ofm_version_number"] = fundingRecords[0].GetAttributeValue<int>("ofm_version_number") + 1;
newFundingRecord["ofm_funding_number"] = ofmFundingNumberBase + "-" + (fundingRecords[0].GetAttributeValue<int>("ofm_version_number") + 1).ToString("00"); // Primary coloumn
var newVersionNumber = applicationRecord[0].GetAttributeValue<int>("ofm_funding_version_number") + 1;
newFundingRecord["ofm_version_number"] = newVersionNumber;
newFundingRecord["ofm_funding_number"] = ofmFundingNumberBase + "-" + newVersionNumber.ToString("00"); // Primary coloumn
newFundingRecord["ofm_application"] = new EntityReference("ofm_application", recordId);
newFundingRecord["ofm_rate_schedule"] = (rateSchedualId == null || rateSchedualId == Guid.Empty) ? null : new EntityReference("ofm_rate_schedule", rateSchedualId);
//newFundingRecord["statuscode"] = new OptionSetValue((int) ofm_funding_StatusCode.FAReview);
service.Create(newFundingRecord);



//Update application version number
Entity newupdate = new Entity();
newupdate.LogicalName = entity.LogicalName;
newupdate["ofm_applicationid"] = entity["ofm_applicationid"];
newupdate["ofm_funding_version_number"] = newVersionNumber;
service.Update(newupdate);


tracingService.Trace("\nThis is a resubmisstion.Create Funding records successfully.");
}
}
Expand All @@ -163,4 +169,4 @@ protected override void Execute(CodeActivityContext executionContext)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ public sealed class OutputModStartAndEndDate : CodeActivity
[Input("Application")]
public InArgument<EntityReference> application { get; set; }

[Input("Version")]
[ReferenceTarget("ofm_funding")]
[RequiredArgument]
public InArgument<int> version { get; set; }
[Input("Funding")]
public InArgument<EntityReference> funding { get; set; }

[Output("Start Date")]
public OutArgument<DateTime> startDate { get; set; }
Expand All @@ -39,28 +40,36 @@ protected override void Execute(CodeActivityContext executionContext)
IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);
tracingService.Trace("{0}{1}", "Start Custom Workflow Activity: OutputMODStartAndEndDate", DateTime.Now.ToLongTimeString());
var application = this.application.Get(executionContext);
var version = this.version.Get(executionContext);
var funding = this.funding.Get(executionContext);

try
{
var fundingRequest = new QueryExpression()
{
EntityName = ofm_funding.EntityLogicalName,
ColumnSet = new ColumnSet(new string[] { ofm_funding.Fields.ofm_end_date, ofm_funding.Fields.ofm_application }),
ColumnSet = new ColumnSet(new string[] { ofm_funding.Fields.ofm_end_date, ofm_funding.Fields.ofm_application, ofm_funding.Fields.ofm_version_number }),
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression(ofm_funding.Fields.ofm_version_number, ConditionOperator.Equal, version - 1),
new ConditionExpression(ofm_funding.Fields.ofm_application, ConditionOperator.Equal, application.Id)
new ConditionExpression(ofm_funding.Fields.ofm_application, ConditionOperator.Equal, application.Id),
new ConditionExpression("ofm_fundingid", ConditionOperator.NotEqual, funding.Id)
}
},
Orders =
{
new OrderExpression("ofm_version_number", OrderType.Descending)
}
};

var d365Funding = service.RetrieveMultiple(fundingRequest);

tracingService.Trace("{0}{1}", "Fundings:", d365Funding.Entities.Count);
tracingService.Trace("{0}{1}", "Latest Funding: ", d365Funding[0].Id);

if (d365Funding != null && d365Funding.Entities.Count > 0 && d365Funding[0].Attributes.Contains(ofm_funding.Fields.ofm_end_date))
{

RetrieveRequest timeZoneCode = new RetrieveRequest
{
ColumnSet = new ColumnSet(new string[] { UserSettings.Fields.timezonecode }),
Expand Down
1 change: 1 addition & 0 deletions OFM.Infrastructure.WebAPI/Models/Fundings/Fundings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public class SupplementaryApplication : ofm_allowance
public new decimal? ofm_transport_odometer { get; set; }
public new decimal? ofm_monthly_amount { get; set; }
public new decimal? ofm_retroactive_amount { get; set; }
public string? ofm_funding_number { get; set; }
public new SupplementarySchedule? ofm_supplementary_schedule { get; set; }
public string? _ofm_application_value { get; set; }
[property: JsonPropertyName("con.ofm_first_name")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public async Task<JsonObject> CreateAllowanceEmail(SupplementaryApplication allo
//var allowanceStatusReason = allowance.statuscode;
Guid applicationPrimaryContact = (Guid)allowance._ofm_contact_value != null ? (Guid)allowance._ofm_contact_value : Guid.Empty;
Guid submittedBy = allowance._ofm_summary_submittedby_value != null ? (Guid)allowance._ofm_summary_submittedby_value : Guid.Empty;
var fundingNumber = allowance.ofm_funding_number_base;
var fundingNumber = allowance.ofm_funding_number;
var effectiveDate = allowance.ofm_start_date;
var retroActiveDate = allowance.ofm_retroactive_date;
var VIN = allowance.ofm_transport_vehicle_vin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public string RequestUri
<attribute name="ofm_retroactive_date" />
<attribute name="ofm_retroactive_amount" />
<attribute name="ofm_funding_amount" />
<attribute name="ofm_funding_number" />
<filter>
<condition attribute="ofm_allowanceid" operator="eq" value="{_allowanceId}" />
</filter>
Expand Down

0 comments on commit 2538912

Please sign in to comment.