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

fix(premium-schedule): added 0 and 4 as acceptable inputs #440

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export class CreatePremiumScheduleDto {

@IsNumber()
@IsNotEmpty()
@Min(1)
@Max(3)
@Min(0)
@Max(4)
@ApiProperty({
example: 1,
description: 'Payment frequency. It can be: 1 -> Monthly, 2 -> Quarterly, 3-> Semi-annually or 4 -> Annually',
description: 'Payment frequency. It can be: 0 -> Null (At maturity), 1 -> Monthly, 2 -> Quarterly, 3-> Semi-annually or 4 -> Annually',
})
readonly premiumFrequencyId: number;

Expand Down
2 changes: 1 addition & 1 deletion test/docs/__snapshots__/get-docs-yaml.api-test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ components:
type: number
example: 1
description: >-
Payment frequency. It can be: 1 -> Monthly, 2 -> Quarterly, 3->
Payment frequency. It can be: 0 -> Null (At maturity), 1 -> Monthly, 2 -> Quarterly, 3->
Semi-annually or 4 -> Annually
guaranteeCommencementDate:
format: date-time
Expand Down
52 changes: 50 additions & 2 deletions test/premium-schedules/premium-schedules.api-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@ describe('Premium schedules', () => {
/**
* To get existing premium schedules we need to generate them first.
*/
it('POST /premium/schedule as BSS with `At maturity` fee frequency', async () => {
const createSchedules = [
{
facilityURN: chance.natural({ min: 10000000, max: 99999999 }),
productGroup: PRODUCTS.BS,
premiumTypeId: 1,
premiumFrequencyId: 0,
guaranteeCommencementDate: '2023-01-19',
guaranteeExpiryDate: '2023-02-19',
guaranteePercentage: 80,
guaranteeFeePercentage: 1.35,
dayBasis: '360',
exposurePeriod: 1,
cumulativeAmount: null,
maximumLiability: 40000,
},
];
const postResponse = await api.post(createSchedules).to('/premium/schedule');

expect(postResponse.status).toBe(201);
expect(postResponse.body).toHaveLength(1);
expect(postResponse.body).toEqual(expect.arrayContaining([expect.objectContaining(premiumScheduleSchema)]));
});

it('POST /premium/schedule and then GET /premium/segments/{facilityId}', async () => {
const createSchedules = [
{
Expand Down Expand Up @@ -81,7 +105,7 @@ describe('Premium schedules', () => {
facilityURN: chance.natural({ min: 10000000, max: 99999999 }),
productGroup: PRODUCTS.BS,
premiumTypeId: 1,
premiumFrequencyId: 1,
premiumFrequencyId: 2,
guaranteeCommencementDate: '2023-01-19',
guaranteeExpiryDate: '2023-02-19',
guaranteePercentage: 80,
Expand All @@ -105,7 +129,31 @@ describe('Premium schedules', () => {
facilityURN: chance.natural({ min: 10000000, max: 99999999 }),
productGroup: PRODUCTS.BS,
premiumTypeId: 1,
premiumFrequencyId: 1,
premiumFrequencyId: 3,
guaranteeCommencementDate: '2023-01-19',
guaranteeExpiryDate: '2023-02-19',
guaranteePercentage: 80,
guaranteeFeePercentage: 1.35,
dayBasis: '360',
exposurePeriod: 1,
cumulativeAmount: null,
maximumLiability: 40000,
},
];
const postResponse = await api.post(createSchedules).to('/premium/schedule');

expect(postResponse.status).toBe(201);
expect(postResponse.body).toHaveLength(1);
expect(postResponse.body).toEqual(expect.arrayContaining([expect.objectContaining(premiumScheduleSchema)]));
});

it('POST /premium/schedule as EWCS with `Annually` fee frequency', async () => {
const createSchedules = [
{
facilityURN: chance.natural({ min: 10000000, max: 99999999 }),
productGroup: PRODUCTS.BS,
premiumTypeId: 1,
premiumFrequencyId: 4,
guaranteeCommencementDate: '2023-01-19',
guaranteeExpiryDate: '2023-02-19',
guaranteePercentage: 80,
Expand Down
Loading