Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORV2-2938 - Refund multiple payment methods #1695

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
da8363c
feat: ORV2-2857 - Update DDL model of Receipt and Transaction
praju-aot Oct 21, 2024
ec7f9e5
Formatting
praju-aot Oct 23, 2024
0094296
create RefundDetails component
glen-aot Oct 30, 2024
eef939f
add refundAmount, refundTransactionId and chequeRefund columns
glen-aot Oct 31, 2024
cda6616
implement correct RefundDetails values and update TransactionHistoryT…
glen-aot Nov 4, 2024
855f078
wrap TransactionHistoryTable in FormContextProvider
glen-aot Nov 4, 2024
1f86354
Merge remote-tracking branch 'origin/main' into ORV2-2938
glen-aot Nov 4, 2024
73c151f
create useRefumdPermitMutation hook and refundPermit API function
glen-aot Nov 6, 2024
c3ffe59
Refund to multiple payment methods
praju-aot Nov 7, 2024
f0dd2d8
Update DB version
praju-aot Nov 7, 2024
4d185c1
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Nov 7, 2024
5fcae06
Receipt document generation
praju-aot Nov 7, 2024
86c02a3
Template changes and code review changes
praju-aot Nov 8, 2024
7a3146b
Update void endpoint to process refunds to multiple payment methods
praju-aot Nov 8, 2024
cdc8d3a
Code review Comments
praju-aot Nov 8, 2024
9b2cac8
Merge remote-tracking branch 'origin/main' into ORV2-2938
glen-aot Nov 8, 2024
db7f641
Merge remote-tracking branch 'origin/ORV2-2857-be-refund-to-multiple-…
glen-aot Nov 8, 2024
1cd396e
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Nov 8, 2024
d2b5c29
Updated the version from 47 to 48
praju-aot Nov 8, 2024
1e7116a
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Nov 8, 2024
1639ceb
refactor onSubmit
glen-aot Nov 12, 2024
9b8920d
Code merge conflicts
praju-aot Nov 13, 2024
14a7f0f
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Nov 13, 2024
f419780
Merge remote-tracking branch 'origin/ORV2-2857-be-refund-to-multiple-…
glen-aot Nov 13, 2024
b685cc9
update ORBC_FormTypes
glen-aot Nov 15, 2024
ca4c4fd
Merge remote-tracking branch 'origin/main' into ORV2-2938
glen-aot Nov 22, 2024
a7479d0
prepend refundData to all relevant fields in TransactionHistoryTable
glen-aot Nov 22, 2024
34cf1d1
Merge conflicts
praju-aot Nov 26, 2024
dad1677
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Nov 26, 2024
07bd603
void steps
glen-aot Nov 27, 2024
991880f
refactor handleAmend
glen-aot Dec 2, 2024
2a207c3
amend/void/revoke
glen-aot Dec 4, 2024
d857fde
Resolve code merge conflicts
praju-aot Dec 4, 2024
578e9ea
Code conflict review
praju-aot Dec 4, 2024
f7cd2d7
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Dec 4, 2024
56e5379
pre merge
glen-aot Dec 4, 2024
64ed0db
Merge remote-tracking branch 'origin/main' into ORV2-2938
glen-aot Dec 5, 2024
78d73f5
Code merge conflicts
praju-aot Dec 5, 2024
e0cdda6
Merge remote-tracking branch 'origin/ORV2-2857-be-refund-to-multiple-…
glen-aot Dec 5, 2024
a68e656
update chequeRefund checkbox disabled behaviour and update refundAmou…
glen-aot Dec 6, 2024
e3c973c
Merge branch 'main' into ORV2-2938
glen-aot Dec 9, 2024
0bd690f
rename type MultiplePaymentMethodRefundData to RefundFormData in comm…
glen-aot Dec 9, 2024
0a80808
Merge remote-tracking branch 'origin/main' into ORV2-2938
glen-aot Dec 9, 2024
25db008
Merge remote-tracking branch 'refs/remotes/origin/ORV2-2938' into ORV…
glen-aot Dec 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 237 additions & 0 deletions database/mssql/scripts/versions/revert/v_51_ddl_revert.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET NOCOUNT ON
GO

SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO


IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [permit].[ORBC_RECEIPT] ADD [TRANSACTION_ID] [bigint] NULL

IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [permit].[ORBC_RECEIPT] WITH CHECK ADD CONSTRAINT [ORBC_RECEIPT_TRANSACTION_ID_FK] FOREIGN KEY([TRANSACTION_ID])
REFERENCES [permit].[ORBC_TRANSACTION] ([TRANSACTION_ID])

-- Alter trigger permit.ORBC_RCPT_A_S_IUD_TR
PRINT N'Alter trigger permit.ORBC_RCPT_A_S_IUD_TR'
GO
ALTER TRIGGER [permit].[ORBC_RCPT_A_S_IUD_TR] ON permit.[ORBC_RECEIPT] FOR INSERT, UPDATE, DELETE AS
SET NOCOUNT ON
BEGIN TRY
DECLARE @curr_date datetime;
SET @curr_date = getutcdate();
IF NOT EXISTS(SELECT * FROM inserted) AND NOT EXISTS(SELECT * FROM deleted)
RETURN;

-- historical
IF EXISTS(SELECT * FROM deleted)
update [permit].[ORBC_RECEIPT_HIST] set END_DATE_HIST = @curr_date where RECEIPT_ID in (select RECEIPT_ID from deleted) and END_DATE_HIST is null;

IF EXISTS(SELECT * FROM inserted)
insert into [permit].[ORBC_RECEIPT_HIST] ([RECEIPT_ID], [RECEIPT_NUMBER], [TRANSACTION_ID], [RECEIPT_DOCUMENT_ID], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], _RECEIPT_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST)
select [RECEIPT_ID], [RECEIPT_NUMBER], [TRANSACTION_ID], [RECEIPT_DOCUMENT_ID], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], (next value for [permit].[ORBC_RECEIPT_H_ID_SEQ]) as [_RECEIPT_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted;

END TRY
BEGIN CATCH
IF @@trancount > 0 ROLLBACK TRANSACTION
EXEC orbc_error_handling
END CATCH;
GO

IF @@ERROR <> 0 SET NOEXEC ON
GO

-- Alter trigger permit.ORBC_RCPT_I_S_U_TR
PRINT N'Alter trigger permit.ORBC_RCPT_I_S_U_TR'
GO
ALTER TRIGGER [permit].[ORBC_RCPT_I_S_U_TR] ON permit.[ORBC_RECEIPT] INSTEAD OF UPDATE AS
SET NOCOUNT ON
BEGIN TRY
IF NOT EXISTS(SELECT * FROM deleted)
RETURN;

-- validate concurrency control
if exists (select 1 from inserted, deleted where inserted.CONCURRENCY_CONTROL_NUMBER != deleted.CONCURRENCY_CONTROL_NUMBER+1 AND inserted.RECEIPT_ID = deleted.RECEIPT_ID)
raiserror('CONCURRENCY FAILURE.',16,1)


-- update statement
update [permit].[ORBC_RECEIPT]
set "RECEIPT_NUMBER" = inserted."RECEIPT_NUMBER",
"TRANSACTION_ID" = inserted."TRANSACTION_ID",
"RECEIPT_DOCUMENT_ID" = inserted."RECEIPT_DOCUMENT_ID",
"APP_LAST_UPDATE_TIMESTAMP" = inserted."APP_LAST_UPDATE_TIMESTAMP",
"APP_LAST_UPDATE_USERID" = inserted."APP_LAST_UPDATE_USERID",
"APP_LAST_UPDATE_USER_GUID" = inserted."APP_LAST_UPDATE_USER_GUID",
"APP_LAST_UPDATE_USER_DIRECTORY" = inserted."APP_LAST_UPDATE_USER_DIRECTORY",
"CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER"
, DB_LAST_UPDATE_TIMESTAMP = getutcdate()
, DB_LAST_UPDATE_USERID = user_name()
from [permit].[ORBC_RECEIPT]
inner join inserted
on (ORBC_RECEIPT.RECEIPT_ID = inserted.RECEIPT_ID);

END TRY
BEGIN CATCH
IF @@trancount > 0 ROLLBACK TRANSACTION
EXEC orbc_error_handling
END CATCH;
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
DISABLE TRIGGER [permit].[ORBC_RCPT_I_S_U_TR] ON permit.[ORBC_RECEIPT]
GO

IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE r
SET TRANSACTION_ID = t.TRANSACTION_ID
FROM [permit].[ORBC_RECEIPT] r
INNER JOIN [permit].[ORBC_TRANSACTION] t ON t.RECEIPT_ID = r.RECEIPT_ID;

IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [permit].[ORBC_RECEIPT] ALTER COLUMN [TRANSACTION_ID] [bigint] NOT NULL

IF @@ERROR <> 0 SET NOEXEC ON
GO
AlTER TABLE [permit].[ORBC_RECEIPT_HIST] ALTER COLUMN [TRANSACTION_ID] [bigint] NOT NULL


IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [permit].[ORBC_TRANSACTION] DROP CONSTRAINT FK_ORBC_TRANSACTION_RECEIPT_ID

IF @@ERROR <> 0 SET NOEXEC ON
GO
DROP INDEX IX_ORBC_TRANSACTION_RECEIPT_ID_FK ON [permit].[ORBC_TRANSACTION];

IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [permit].[ORBC_TRANSACTION] DROP COLUMN [RECEIPT_ID]

IF @@ERROR <> 0 SET NOEXEC ON
GO
CREATE NONCLUSTERED INDEX IX_ORBC_RECEIPT_TRANSACTION_ID_FK ON [permit].[ORBC_RECEIPT] ([TRANSACTION_ID]);


IF @@ERROR <> 0 SET NOEXEC ON
GO
-- Alter trigger permit.ORBC_TXN_A_S_IUD_TR
PRINT N'Alter trigger permit.ORBC_TXN_A_S_IUD_TR'
GO
ALTER TRIGGER [permit].[ORBC_TXN_A_S_IUD_TR] ON permit.[ORBC_TRANSACTION] FOR INSERT, UPDATE, DELETE AS
SET NOCOUNT ON
BEGIN TRY
DECLARE @curr_date datetime;
SET @curr_date = getutcdate();
IF NOT EXISTS(SELECT * FROM inserted) AND NOT EXISTS(SELECT * FROM deleted)
RETURN;

-- historical
IF EXISTS(SELECT * FROM deleted)
update [permit].[ORBC_TRANSACTION_HIST] set END_DATE_HIST = @curr_date where TRANSACTION_ID in (select TRANSACTION_ID from deleted) and END_DATE_HIST is null;

IF EXISTS(SELECT * FROM inserted)
insert into [permit].[ORBC_TRANSACTION_HIST] ([TRANSACTION_ID], [TRANSACTION_TYPE], [PAYMENT_METHOD_TYPE], [PAYMENT_CARD_TYPE], [TOTAL_TRANSACTION_AMOUNT], [TRANSACTION_SUBMIT_DATE], [TRANSACTION_ORDER_NUMBER], [PG_TRANSACTION_ID], [PG_TRANSACTION_APPROVED], [PG_AUTH_CODE], [PG_TRANSACTION_CARD_TYPE], [PG_TRANSACTION_DATE], [PG_CVD_ID], [PG_PAYMENT_METHOD], [PG_MESSAGE_ID], [PG_MESSAGE_TEXT], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], _TRANSACTION_HIST_ID, END_DATE_HIST, EFFECTIVE_DATE_HIST)
select [TRANSACTION_ID], [TRANSACTION_TYPE], [PAYMENT_METHOD_TYPE], [PAYMENT_CARD_TYPE], [TOTAL_TRANSACTION_AMOUNT], [TRANSACTION_SUBMIT_DATE], [TRANSACTION_ORDER_NUMBER], [PG_TRANSACTION_ID], [PG_TRANSACTION_APPROVED], [PG_AUTH_CODE], [PG_TRANSACTION_CARD_TYPE], [PG_TRANSACTION_DATE], [PG_CVD_ID], [PG_PAYMENT_METHOD], [PG_MESSAGE_ID], [PG_MESSAGE_TEXT], [APP_CREATE_TIMESTAMP], [APP_CREATE_USERID], [APP_CREATE_USER_GUID], [APP_CREATE_USER_DIRECTORY], [APP_LAST_UPDATE_TIMESTAMP], [APP_LAST_UPDATE_USERID], [APP_LAST_UPDATE_USER_GUID], [APP_LAST_UPDATE_USER_DIRECTORY], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP], (next value for [permit].[ORBC_TRANSACTION_H_ID_SEQ]) as [_TRANSACTION_HIST_ID], null as [END_DATE_HIST], @curr_date as [EFFECTIVE_DATE_HIST] from inserted;

END TRY
BEGIN CATCH
IF @@trancount > 0 ROLLBACK TRANSACTION
EXEC orbc_error_handling
END CATCH;
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO


-- Alter trigger permit.ORBC_TXN_I_S_U_TR
PRINT N'Alter trigger permit.ORBC_TXN_I_S_U_TR'
GO
ALTER TRIGGER [permit].[ORBC_TXN_I_S_U_TR] ON permit.[ORBC_TRANSACTION] INSTEAD OF UPDATE AS
SET NOCOUNT ON
BEGIN TRY
IF NOT EXISTS(SELECT * FROM deleted)
RETURN;

-- validate concurrency control
if exists (select 1 from inserted, deleted where inserted.CONCURRENCY_CONTROL_NUMBER != deleted.CONCURRENCY_CONTROL_NUMBER+1 AND inserted.TRANSACTION_ID = deleted.TRANSACTION_ID)
raiserror('CONCURRENCY FAILURE.',16,1)


-- update statement
update [permit].[ORBC_TRANSACTION]
set "TRANSACTION_TYPE" = inserted."TRANSACTION_TYPE",
"PAYMENT_METHOD_TYPE" = inserted."PAYMENT_METHOD_TYPE",
"PAYMENT_CARD_TYPE" = inserted."PAYMENT_CARD_TYPE",
"TOTAL_TRANSACTION_AMOUNT" = inserted."TOTAL_TRANSACTION_AMOUNT",
"TRANSACTION_SUBMIT_DATE" = inserted."TRANSACTION_SUBMIT_DATE",
"TRANSACTION_ORDER_NUMBER" = inserted."TRANSACTION_ORDER_NUMBER",
"PG_TRANSACTION_ID" = inserted."PG_TRANSACTION_ID",
"PG_TRANSACTION_APPROVED" = inserted."PG_TRANSACTION_APPROVED",
"PG_AUTH_CODE" = inserted."PG_AUTH_CODE",
"PG_TRANSACTION_CARD_TYPE" = inserted."PG_TRANSACTION_CARD_TYPE",
"PG_TRANSACTION_DATE" = inserted."PG_TRANSACTION_DATE",
"PG_CVD_ID" = inserted."PG_CVD_ID",
"PG_PAYMENT_METHOD" = inserted."PG_PAYMENT_METHOD",
"PG_MESSAGE_ID" = inserted."PG_MESSAGE_ID",
"PG_MESSAGE_TEXT" = inserted."PG_MESSAGE_TEXT",
"APP_LAST_UPDATE_TIMESTAMP" = inserted."APP_LAST_UPDATE_TIMESTAMP",
"APP_LAST_UPDATE_USERID" = inserted."APP_LAST_UPDATE_USERID",
"APP_LAST_UPDATE_USER_GUID" = inserted."APP_LAST_UPDATE_USER_GUID",
"APP_LAST_UPDATE_USER_DIRECTORY" = inserted."APP_LAST_UPDATE_USER_DIRECTORY",
"CONCURRENCY_CONTROL_NUMBER" = inserted."CONCURRENCY_CONTROL_NUMBER"
, DB_LAST_UPDATE_TIMESTAMP = getutcdate()
, DB_LAST_UPDATE_USERID = user_name()
from [permit].[ORBC_TRANSACTION]
inner join inserted
on (ORBC_TRANSACTION.TRANSACTION_ID = inserted.TRANSACTION_ID);

END TRY
BEGIN CATCH
IF @@trancount > 0 ROLLBACK TRANSACTION
EXEC orbc_error_handling
END CATCH;
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
DISABLE TRIGGER [permit].[ORBC_TXN_I_S_U_TR] ON permit.[ORBC_TRANSACTION]
GO


IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [permit].[ORBC_TRANSACTION_HIST] DROP COLUMN [RECEIPT_ID]

IF @@ERROR <> 0 SET NOEXEC ON
GO
DECLARE @VersionDescription VARCHAR(255)
SET @VersionDescription = 'Reverting addition of RECEIPT_ID col to ORBC_TRANSACTION and dropping TRANSACTION_ID from ORBC_RECEIPT.'

INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [RELEASE_DATE]) VALUES (50, @VersionDescription, getutcdate())

IF @@ERROR <> 0 SET NOEXEC ON
GO
COMMIT TRANSACTION
IF @@ERROR <> 0 SET NOEXEC ON
GO
DECLARE @Success AS BIT
SET @Success = 1
SET NOEXEC OFF
IF (@Success = 1) PRINT 'The database update succeeded'
ELSE BEGIN
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
PRINT 'The database update failed'
END
GO
Loading
Loading