Skip to content

Commit

Permalink
fix(premium-schedule): added 0 and 4 as acceptable inputs (#440)
Browse files Browse the repository at this point in the history
## Introduction ✏️ 
Premium schedule endpoint did not allow `premiumFrequencyId` with valid
inputs.

## Resolution ✔️ 
* Updated `min` and `max` decorators.
* Updated documentation.
* Updated API test cases to cater all the `premiumFrequencyId` values (0
- 4)

## Miscellaneous ➕ 
* Dependencies update

Co-authored-by: Abhi Markan <abhi.markan@ukexportfinance.gov.uk>
  • Loading branch information
abhi-markan and Abhi Markan committed Sep 1, 2023
1 parent d62f78c commit 270b405
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
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

0 comments on commit 270b405

Please sign in to comment.