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

feat:ORV2-2857 BE Refund To Multiple Payment Methods #1660

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 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
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
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
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
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
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
78d73f5
Code merge conflicts
praju-aot Dec 5, 2024
64ee0ef
Resolve code conflicts with main
praju-aot Dec 17, 2024
8d89736
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Dec 17, 2024
d1feb4d
Resolve code conflict
praju-aot Jan 8, 2025
11e4e66
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Jan 8, 2025
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
7 changes: 5 additions & 2 deletions vehicles/src/common/helper/format-template-data.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ export const formatTemplateData = (
template.clientNumber = companyInfo.clientNumber;
template.companyAlternateName = companyInfo.alternateName;

// Format Fee Summary
const transcation = permit.permitTransactions?.at(0)?.transaction;

// Format Fee Summary
template.permitData.feeSummary = formatAmount(
transcation.transactionTypeId,
permit.permitTransactions?.at(0)?.transactionAmount,
permit.permitTransactions?.reduce(
(accumulator, item) => accumulator + item.transactionAmount,
0,
),
).toString();

if (permit.revision > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { AutoMap } from '@automapper/classes';
import { ApiProperty } from '@nestjs/swagger';
import {
IsEnum,
IsNumber,
IsOptional,
IsString,
Length,
MaxLength,
Min,
} from 'class-validator';
import { PaymentCardType } from '../../../../../common/enum/payment-card-type.enum';
import { PaymentMethodType } from '../../../../../common/enum/payment-method-type.enum';

export class PaymentTransactionDto {
@AutoMap()
@ApiProperty({
example: '10000148',
required: false,
description:
'Bambora-assigned eight-digit unique id number used to identify an individual transaction.',
})
@IsOptional()
@IsString()
@MaxLength(20)
pgTransactionId: string;

@AutoMap()
@ApiProperty({
example: 'CC',
required: false,
description: 'Represents the payment method of a transaction.',
})
@IsOptional()
@IsString()
@Length(1, 2)
pgPaymentMethod: string;

@AutoMap()
@ApiProperty({
example: '30.00',
description: 'Represents the amount of the transaction.',
})
@IsNumber()
@Min(0)
transactionAmount: number;

@AutoMap()
@ApiProperty({
enum: PaymentMethodType,
example: PaymentMethodType.WEB,
description: 'The identifier of the user selected payment method.',
})
@IsEnum(PaymentMethodType)
paymentMethodTypeCode: PaymentMethodType;

@AutoMap()
@ApiProperty({
example: PaymentCardType.VISA,
enum: PaymentCardType,
description: 'The payment types.',
required: false,
})
@IsOptional()
@IsEnum(PaymentCardType)
paymentCardTypeCode?: PaymentCardType;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { AutoMap } from '@automapper/classes';
import { ApiProperty } from '@nestjs/swagger';
import {
ArrayMinSize,
IsArray,
IsNumberString,
MaxLength,
ValidateNested,
} from 'class-validator';

import { PaymentTransactionDto } from '../common/payment-transaction.dto';
import { Type } from 'class-transformer';

export class CreateRefundTransactionDto {
@AutoMap()
@ApiProperty({
description: 'Application/Permit Id.',
example: '1',
})
@IsNumberString()
@MaxLength(20)
applicationId: string;

@AutoMap()
@ApiProperty({
description: 'The transaction details specific to application/permit.',
required: true,
type: [PaymentTransactionDto],
})
@IsArray()
@ValidateNested({ each: true })
@ArrayMinSize(1)
@Type(() => PaymentTransactionDto)
transactions: PaymentTransactionDto[];
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import {
Entity,
Column,
PrimaryGeneratedColumn,
OneToMany,
} from 'typeorm';
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm';
import { AutoMap } from '@automapper/classes';
import { Base } from '../../../common/entities/base.entity';
import { Transaction } from './transaction.entity';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
CLIENT_USER_ROLE_LIST,
IDIRUserRole,
} from '../../../common/enum/user-role.enum';
import { CreateRefundTransactionDto } from './dto/request/create-refund-transaction.dto';

@ApiBearerAuth()
@ApiTags('Payment')
Expand Down Expand Up @@ -90,6 +91,34 @@ export class PaymentController {
return paymentDetails;
}

@ApiCreatedResponse({
description: 'The Transaction Resource',
isArray: true,
type: ReadTransactionDto,
})
@Permissions({
allowedIdirRoles: [
IDIRUserRole.PPC_CLERK,
IDIRUserRole.SYSTEM_ADMINISTRATOR,
IDIRUserRole.CTPO,
],
})
@Post('refund')
async createRefundTransactionDetails(
@Req() request: Request,
@Body() { applicationId, transactions }: CreateRefundTransactionDto,
): Promise<ReadTransactionDto[]> {
const currentUser = request.user as IUserJWT;

const paymentDetails = await this.paymentService.createRefundTransactions({
currentUser,
applicationId,
transactions,
});

return paymentDetails;
}

@ApiOkResponse({
description: 'The Payment Gateway Transaction Resource',
type: UpdatePaymentGatewayTransactionDto,
Expand Down
Loading
Loading