Skip to content

Commit

Permalink
Updated payment issues on feedback line
Browse files Browse the repository at this point in the history
  • Loading branch information
Anjana Yadav committed May 15, 2024
1 parent a68f3ef commit f9dedd1
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using FixedWidthParserWriter;
using ECC.Core.DataContext;
using EntityReference = OFM.Infrastructure.WebAPI.Messages.EntityReference;
using System.Security.Cryptography;



Expand Down Expand Up @@ -52,7 +53,7 @@ public string RequestUri
<order attribute="ofm_name" descending="false" />
<filter type="and">
<condition attribute="modifiedon" operator="on-or-after" value="{DateTime.UtcNow.AddDays(-1)}" />
<condition attribute="ofm_feedback_file_name" operator="not-null" />
<condition attribute="ofm_feedback_file_name" operator="like" value="%{DateTime.UtcNow.AddDays(-1).ToString("yyyyMMdd")}%" />
</filter>
</entity>
</fetch>
Expand Down Expand Up @@ -242,18 +243,20 @@ public async Task<JsonObject> RunProcessAsync(ID365AppUserService appUserService
serializedPayData?.ForEach(pay =>
{
var line = headers.SelectMany(p=>p.feedbackLine).SingleOrDefault(pl => pl.ILInvoice == pay.ofm_invoice_number && pl.ILDescription.StartsWith(string.Concat(pay.ofm_application_number, " ", pay.ofm_payment_type)));
var header = headers.Where(p=>p.IHInvoice==pay.ofm_invoice_number).First();
string casResponse = (line?.ILCode != "0000")?string.Concat("Error:", line?.ILCode, " ", line?.ILError) : string.Empty;
casResponse += (header.IHCode != "0000") ? string.Concat(header.IHCode, " ", header.IHError) : string.Empty;
var header = headers.Where(p=>p.IHInvoice==pay.ofm_invoice_number).FirstOrDefault();
if (line != null && header != null)
{
string casResponse = (line?.ILCode != "0000") ? string.Concat("Error:", line?.ILCode, " ", line?.ILError) : string.Empty;
casResponse += (header?.IHCode != "0000") ? string.Concat(header?.IHCode, " ", header?.IHError) : string.Empty;

var payToUpdate = new JsonObject {
var payToUpdate = new JsonObject {
{ofm_payment.Fields.ofm_cas_response, casResponse},
{ofm_payment.Fields.statecode,(int)((line?.ILCode=="0000" &&header.IHCode=="0000") ?ofm_payment_statecode.Inactive:ofm_payment_statecode.Active)},
{ofm_payment.Fields.statuscode,(int)((line?.ILCode=="0000" && header.IHCode=="0000")?ofm_payment_StatusCode.Paid:ofm_payment_StatusCode.ProcessingERROR)},
{ofm_payment.Fields.statecode,(int)((line?.ILCode=="0000" &&header?.IHCode=="0000") ?ofm_payment_statecode.Inactive:ofm_payment_statecode.Active)},
{ofm_payment.Fields.statuscode,(int)((line?.ILCode=="0000" && header?.IHCode=="0000")?ofm_payment_StatusCode.Paid:ofm_payment_StatusCode.ProcessingERROR)},
};
updatePayRequests.Add(new D365UpdateRequest(new EntityReference(ofm_payment.EntityLogicalCollectionName, new Guid(pay.ofm_paymentid)), payToUpdate));

updatePayRequests.Add(new D365UpdateRequest(new EntityReference(ofm_payment.EntityLogicalCollectionName, new Guid(pay.ofm_paymentid)), payToUpdate));

}
});

var step2BatchResult = await d365WebApiService.SendBatchMessageAsync(appUserService.AZSystemAppUser, updatePayRequests, null);
Expand Down

0 comments on commit f9dedd1

Please sign in to comment.