Skip to content

Commit

Permalink
Merging all the changes for the October release
Browse files Browse the repository at this point in the history
Merging all the changes for the October release
  • Loading branch information
dragos-dobre authored Nov 23, 2021
2 parents f0b55e8 + e8ffe59 commit 5c164d3
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
using OpenImis.DB.SqlServer;
using OpenImis.ModulesV3.FeedbackModule.Models;
using OpenImis.ModulesV3.Helpers;
using OpenImis.ModulesV3.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -107,13 +109,13 @@ public int Post(FeedbackRequest feedbackClaim)
using (var reader = cmd.ExecuteReader())
{
// Displaying errors in the Stored Procedure in Debug mode
//do
//{
// while (reader.Read())
// {
// Debug.WriteLine("Error/Warning: " + reader.GetValue(0));
// }
//} while (reader.NextResult());
do
{
while (reader.Read())
{
Debug.WriteLine("Error/Warning: " + reader.GetValue(0));
}
} while (reader.NextResult());
}
}

Expand Down Expand Up @@ -167,10 +169,10 @@ join HF in imisContext.TblHf on C.Hfid equals HF.HfId
HFCode = HF.Hfcode,
HFName = HF.Hfname,
ClaimCode = C.ClaimCode,
DateFrom = C.DateFrom.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture),
DateTo = C.DateTo.Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture),
DateFrom = C.DateFrom.ToString(DateTimeFormats.IsoDateFormat, CultureInfo.InvariantCulture),
DateTo = C.DateTo.Value.ToString(DateTimeFormats.IsoDateFormat, CultureInfo.InvariantCulture),
Phone = O.Phone,
FeedbackPromptDate = F.FeedbackPromptDate.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)
FeedbackPromptDate = F.FeedbackPromptDate.ToString(DateTimeFormats.IsoDateFormat, CultureInfo.InvariantCulture)
})
.ToList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public List<GetPolicyRenewalModel> Get(string officerCode)
return response;
}

// TODO Change the RV assignment codes. It should be on the list for better understanding
// TODO Add a RV for missing EO or previous policy (currently -5)
public int Post(PolicyRenewalModel policy)
{
int RV = (int)Errors.Renewal.Rejected;
Expand Down Expand Up @@ -149,27 +149,45 @@ public int Post(PolicyRenewalModel policy)
}

int tempRV = (int)returnParameter.Value;
bool moveToRejected = false;

if (tempRV == 0 || tempRV == -4)
switch (tempRV)
{
RV = (int)Errors.Renewal.Accepted;
case 0:
RV = (int)Errors.Renewal.Accepted;
break;
case -2:
moveToRejected = true;
RV = (int)Errors.Renewal.GracePeriodExpired;
break;
case -4:
RV = (int)Errors.Renewal.AlreadyAccepted;
break;
case -1:
moveToRejected = true;
RV = (int)Errors.Renewal.UnexpectedException;
break;
case -5:
moveToRejected = true;
RV = (int)Errors.Renewal.Rejected;
break;
default:
moveToRejected = true;
RV = (int)Errors.Renewal.Rejected;
break;
}
else if (tempRV == -1 || tempRV == -2 || tempRV == -3)

if(moveToRejected)
{
if (File.Exists(fromPhoneRenewalDir + fileName))
{
File.Move(fromPhoneRenewalDir + fileName, fromPhoneRenewalRejectedDir + fileName);
}
RV = (int)Errors.Renewal.Rejected;
}
else
{
RV = (int)Errors.Renewal.Rejected;
}
}
}

if(RV == (int)Errors.Renewal.Accepted)
if (RV == (int)Errors.Renewal.Accepted)
{
RV = UpdateControlNumber(policy);

Expand Down Expand Up @@ -256,38 +274,33 @@ join O in imisContext.TblOfficer on P.OfficerId equals O.OfficerId

public int UpdateControlNumber(PolicyRenewalModel renewal)
{
if(!String.IsNullOrEmpty(renewal.ControlNumber))
if (!String.IsNullOrEmpty(renewal.ControlNumber))
{
var context = new ImisDB();
var policyId = context.TblPolicyRenewals.Where(r => r.RenewalId == renewal.RenewalId).Select(r => r.PolicyId).FirstOrDefault();
if (policyId > 0)
{
var sSQL = @"UPDATE PD SET InsuranceNumber = @InsuranceNumber, PolicyStage = Pol.PolicyStage, enrollmentDate = Pol.EnrollDate, ValidityFrom = GETDATE()

var sSQL = @"UPDATE PD SET InsuranceNumber = @InsuranceNumber, PolicyStage = N'R', ValidityFrom = GETDATE()
FROM tblControlNumber CN
INNER JOIN tblPaymentDetails PD ON CN.PaymentId = PD.PaymentID
INNER JOIN tblPolicy Pol ON Pol.PolicyID = @PolicyId
WHERE CN.ValidityTo IS NULL
AND CN.ControlNumber = @ControlNumber;";

SqlParameter[] parameters =
{
SqlParameter[] parameters =
{
new SqlParameter("@ControlNumber", renewal.ControlNumber),
new SqlParameter("@PolicyId", policyId),
new SqlParameter("@InsuranceNumber", renewal.CHFID)
};

try
{
var dh = new DB.SqlServer.DataHelper.DataHelper(_configuration);
dh.Execute(sSQL, parameters, CommandType.Text);
}
catch (Exception ex)
{

return (int)Errors.Renewal.CouldNotUpdateControlNumber;
}
try
{
var dh = new DB.SqlServer.DataHelper.DataHelper(_configuration);
dh.Execute(sSQL, parameters, CommandType.Text);
}
catch (Exception ex)
{

return (int)Errors.Renewal.CouldNotUpdateControlNumber;
}

//}
}

return (int)Errors.Renewal.Accepted;
Expand Down
21 changes: 21 additions & 0 deletions OpenImis.RestApi/Properties/PublishProfiles/FolderProfile2.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>True</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>CHFRelease</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>D:\Projects\Published\RestApi\CHF-CHFRelease</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>netcoreapp2.1</TargetFramework>
<ProjectGuid>0f650c61-a020-4549-ac0c-c49f0334e2d7</ProjectGuid>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>
4 changes: 1 addition & 3 deletions OpenImis.RestApi/appsettings.Production.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"ConnectionStrings": {
"IMISDatabase": "Server=Server;Database=IMIS;User ID=User;Password=Password"
},
"JwtIssuer": "http://openimis.org",
"JwtAudience": "http://openimis.org",
"JwtExpireDays": 5,

"Log4NetCore": {
"PropertyOverrides": [
{
Expand Down
4 changes: 4 additions & 0 deletions OpenImis.RestApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
}
}
},
"Language": {
"Primary": "english,en,primary,0,1",
"Languages": [ "en", "fr" ]
},
"AppPrefixDir": "",
"AppSettings": {
"FromPhone_Renewal": "C:\\inetpub\\wwwroot\\openIMIS\\FromPhone\\Renewal",
Expand Down
10 changes: 3 additions & 7 deletions OpenImis.ePayment/Data/ImisBasePayment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -866,14 +866,12 @@ public async Task CancelPayment(int payment_id)
public async void updateReconciliatedPaymentAsync(string billId, int reconId)
{
var sSQL = @"UPDATE tblPayment
SET PaymentStatus = @PaymentStatus,
SpReconcReqId = @SpReconcReqId,
SET SpReconcReqId = @SpReconcReqId,
ReconciliationDate = GETDATE()
WHERE PaymentID = @PaymentID;";

SqlParameter[] parameters = {
new SqlParameter("@PaymentID", billId),
new SqlParameter("@PaymentStatus", PaymentStatus.Reconciliated),
new SqlParameter("@SpReconcReqId", reconId)
};

Expand All @@ -891,14 +889,12 @@ public async void updateReconciliatedPaymentAsync(string billId, int reconId)
public async void updateReconciliatedPaymentError(string billId, int reconId)
{
var sSQL = @"UPDATE tblPayment
SET PaymentStatus = @PaymentStatus,
SpReconcReqId = @SpReconcReqId,
SET SpReconcReqId = @SpReconcReqId,
ReconciliationDate = GETDATE()
WHERE PaymentID = @PaymentID;";

SqlParameter[] parameters = {
new SqlParameter("@PaymentID", billId),
new SqlParameter("@PaymentStatus", PaymentStatus.FailedReconciliated),
new SqlParameter("@SpReconcReqId", reconId)
};

Expand All @@ -919,7 +915,7 @@ public bool CheckPaymentExistError(string id)

SqlParameter[] parameters = {
new SqlParameter("@paymentId", id),
new SqlParameter("@PaymentStatus", PaymentStatus.FailedReconciliated)
new SqlParameter("@PaymentStatus", PaymentStatus.FailedMatchPayment)
};
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public IActionResult GetReconciliation([FromBody] gepgSpReconcResp model)
imisPayment.updateReconciliatedPaymentAsync(recon.SpBillId, model.ReconcBatchInfo.SpReconcReqId);
//TODO update policy
}
else if (paymentStatus == PaymentStatus.Reconciliated)
else if (paymentStatus == PaymentStatus.Matched)
{
imisPayment.MatchPayment(new MatchModel
{
Expand Down
1 change: 1 addition & 0 deletions OpenImis.ePayment/Escape/Payment/Data/ImisPayment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ WHERE CN.ValidityTo IS NULL
AND P.ValidityTo IS NULL
AND PD.ProductCode = @ProductCode
AND P.OfficerCode IS NULL
AND ISNULL(P.PaymentStatus, 0) IN (0, 1, 2, 3)
)
SELECT CASE WHEN Last3MonthsEnrollment > ControlNumbersLeft THEN Last3MonthsEnrollment - ControlNumbersLeft ELSE 0 END NeedToRequest
FROM RemainingCNs, TotalProductUsage";
Expand Down
4 changes: 2 additions & 2 deletions OpenImis.ePayment/Escape/Payment/Models/PaymentStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace OpenImis.ePayment.Escape.Payment.Models
{
public static class PaymentStatus
{
public static int FailedReconciliated = -5;
public static int FailedMatchPayment = -5;
public static int FailedReceived = -4;
public static int FailedControlNumberReceived = -3;
public static int FailedControlNumberRequested = -2;
Expand All @@ -13,6 +13,6 @@ public static class PaymentStatus
public static int ControlNumberRequested = 2;
public static int ControlNumberReceived = 3;
public static int Received = 4;
public static int Reconciliated = 5;
public static int Matched = 5;
}
}
Loading

0 comments on commit 5c164d3

Please sign in to comment.