Skip to content

Commit 39c306b

Browse files
committed
Merge branch 'develop' into feature/OTC-226
2 parents a7e0502 + 296c9a7 commit 39c306b

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

-1.17 MB
Binary file not shown.

Migration script/openIMIS migration latest.sql

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--- MIGRATION Script from v1.4.2 onward
1+
--- MIGRATION Script from v1.4.2 onward
22

33
------------------------------------------------------------------------------------------
44
------------------------------------------------------------------------------------------
@@ -5113,7 +5113,7 @@ BEGIN
51135113
/*Error Codes
51145114
2- Not valid insurance or missing product code
51155115
3- Not valid enrolment officer code
5116-
4 Enrolment officer code and insurance product code are not compatible
5116+
4 –Enrolment officer code and insurance product code are not compatible
51175117
5- Beneficiary has no policy of specified insurance product for renewal
51185118
6- Can not issue a control number as default indicated prior enrollment and Insuree has not been enrolled yet
51195119
@@ -5726,3 +5726,53 @@ BEGIN
57265726
GROUP BY HFCode
57275727
END
57285728
GO
5729+
5730+
IF OBJECT_ID('[uspLastDateForPayment]', 'P') IS NOT NULL
5731+
DROP PROCEDURE [uspLastDateForPayment]
5732+
GO
5733+
CREATE PROCEDURE [dbo].[uspLastDateForPayment]
5734+
(
5735+
@PolicyId INT
5736+
)
5737+
AS
5738+
BEGIN
5739+
DECLARE @ProdId INT,
5740+
@HasCycle BIT = 0,
5741+
@GracePeriod INT,
5742+
@WaitingPeriod INT,
5743+
@StartDate DATE,
5744+
@PolicyStage CHAR(1),
5745+
@ExpiryDate DATE,
5746+
@EnrollDate DATE,
5747+
@LastDate DATE
5748+
5749+
SELECT @ProdId = ProdId FROM tblPolicy WHERE PolicyId = @PolicyId;
5750+
IF EXISTS(SELECT 1 FROM tblProduct Prod WHERE ProdID = @ProdId AND (StartCycle1 IS NOT NULL OR StartCycle2 IS NOT NULL OR StartCycle3 IS NOT NULL OR StartCycle4 IS NOT NULL))
5751+
SET @HasCycle = 1;
5752+
5753+
SELECT @GracePeriod = CASE PL.PolicyStage WHEN 'N' THEN ISNULL(Prod.GracePeriod, 0) WHEN 'R' THEN ISNULL(Prod.GracePeriodRenewal, 0) END,
5754+
@WaitingPeriod = Prod.WaitingPeriod
5755+
FROM tblProduct Prod
5756+
INNER JOIN tblPolicy PL ON PL.ProdId = Prod.ProdId
5757+
WHERE Prod.ProdId = @ProdId;
5758+
5759+
IF @HasCycle = 1
5760+
BEGIN
5761+
PRINT N'Calculate on Fixed Cycle';
5762+
SELECT @StartDate = StartDate FROM tblPolicy WHERE PolicyId = @PolicyId;
5763+
SET @LastDate = DATEADD(MONTH, @GracePeriod, @StartDate)
5764+
PRINT @LastDate
5765+
END
5766+
ELSE
5767+
BEGIN
5768+
PRINT N'Calculate on Free Cycle';
5769+
SELECT @PolicyStage = PolicyStage, @EnrollDate = EnrollDate, @ExpiryDate = ExpiryDate FROM tblPolicy WHERE PolicyId = @PolicyId;
5770+
IF @PolicyStage = 'N'
5771+
SET @LastDate = DATEADD(MONTH, @WaitingPeriod, @EnrollDate);
5772+
IF @PolicyStage = 'R'
5773+
SET @LastDate = DATEADD(MONTH, @WaitingPeriod, DATEADD(DAY, 1, @ExpiryDate));
5774+
END
5775+
5776+
SELECT DATEADD(DAY, -1, @LastDate) LastDate;
5777+
END
5778+
GO

0 commit comments

Comments
 (0)