Skip to content

Conversation

@Kariamos
Copy link
Contributor

@Kariamos Kariamos commented Feb 2, 2026

This pull request introduces a new POST endpoint for creating "other costs" associated with a campaign, along with the necessary validation, OpenAPI documentation updates, and TypeScript schema changes. The implementation ensures that all required fields are validated and that attachments are properly handled and stored.

API endpoint addition and implementation:

  • Added a new POST endpoint /campaigns/{campaign}/finance/otherCosts to allow creation of campaign "other costs", including OpenAPI documentation, request/response schema, and example payloads.
  • Implemented the handler OtherCostsPostRoute in src/routes/campaigns/campaignId/finance/otherCosts/_post/index.ts, which performs input validation, checks for campaign access, ensures referenced types and suppliers exist, and creates both the cost and its attachments in the database.

Schema and type updates:

  • Updated TypeScript interfaces in src/schema.ts to include the new POST operation, its parameters, request body, and responses for /campaigns/{campaign}/finance/otherCosts. [1] [2] [3]

OpenAPI parameter refactoring:

  • Refactored the OpenAPI path parameter for campaign to use a reusable component reference, ensuring consistency across endpoints.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Tests difference:

New Tests

< Campaign isolation - Should create cost only for specified campaign
< Not enough permissions - Should return 403 if logged in as not admin user
< Not enough permissions - Should return 403 if logged out
< Not enough permissions - Should return 403 if no access to the campaign
< Success - admin permissions - Should accept decimal cost values
< Success - admin permissions - Should create attachments in database
< Success - admin permissions - Should create cost with multiple attachments
< Success - admin permissions - Should create cost with single attachment
< Success - admin permissions - Should create multiple costs independently
< Success - admin permissions - Should create other cost in database
< Success - admin permissions - Should return 201 if logged in as admin
< Success - olp permissions - Should create attachments with olp permissions
< Success - olp permissions - Should create other cost in database with olp permissions
< Success - olp permissions - Should return 201 if logged in as olp with access to campaign
< Success - olp permissions - Should return 403 if olp does not have access to campaign
< Validation errors - Should return 400 if attachment mime_type is empty
< Validation errors - Should return 400 if attachment url is empty
< Validation errors - Should return 400 if attachments array is empty
< Validation errors - Should return 400 if cost is 0
< Validation errors - Should return 400 if cost is negative
< Validation errors - Should return 400 if description is empty
< Validation errors - Should return 400 if description is only whitespace
< Validation errors - Should return 400 if supplier_id does not exist
< Validation errors - Should return 400 if type_id does not exist

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 79.601% (+0.07%) from 79.53%
when pulling b4a6458 on UN-2278-post-other-costs
into 2077fa8 on UN-2274-other-costs.

@Kariamos Kariamos merged commit 76f0fc9 into UN-2274-other-costs Feb 2, 2026
4 checks passed
@Kariamos Kariamos deleted the UN-2278-post-other-costs branch February 2, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants