From f9dedd1dc72a444f1ba9ea7b7f79f4ee3dcd7df9 Mon Sep 17 00:00:00 2001 From: Anjana Yadav Date: Wed, 15 May 2024 10:52:51 -0700 Subject: [PATCH] Updated payment issues on feedback line --- .../P510ReadPaymentResponseProvider.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/OFM.Infrastructure.WebAPI/Services/Processes/Payments/P510ReadPaymentResponseProvider.cs b/OFM.Infrastructure.WebAPI/Services/Processes/Payments/P510ReadPaymentResponseProvider.cs index 52e7c779..7e14e19b 100644 --- a/OFM.Infrastructure.WebAPI/Services/Processes/Payments/P510ReadPaymentResponseProvider.cs +++ b/OFM.Infrastructure.WebAPI/Services/Processes/Payments/P510ReadPaymentResponseProvider.cs @@ -11,6 +11,7 @@ using FixedWidthParserWriter; using ECC.Core.DataContext; using EntityReference = OFM.Infrastructure.WebAPI.Messages.EntityReference; +using System.Security.Cryptography; @@ -52,7 +53,7 @@ public string RequestUri - + @@ -242,18 +243,20 @@ public async Task 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);