Skip to content

Patch other costs#519

Merged
Kariamos merged 8 commits intoUN-2274-other-costsfrom
patch-other-costs
Feb 3, 2026
Merged

Patch other costs#519
Kariamos merged 8 commits intoUN-2274-other-costsfrom
patch-other-costs

Conversation

@Kariamos
Copy link
Contributor

@Kariamos Kariamos commented Feb 3, 2026

This pull request introduces the PATCH endpoint for updating "other costs" in a campaign's finance section. The changes include updates to the OpenAPI specification, the TypeScript schema types, and the implementation of the PATCH route handler. The main focus is on enabling partial updates to other cost records, including their attachments, with appropriate validation and error handling.

API Endpoint Additions and Updates:

  • Added a new PATCH endpoint /campaigns/{campaign}/finance/otherCosts to the OpenAPI specification, including request and response schemas, examples, and error responses.
  • Updated the OpenAPI path parameter for campaign to include a description and inline schema, improving clarity and consistency.

TypeScript Schema Updates:

  • Extended the paths and operations interfaces in src/schema.ts to support the new PATCH endpoint, including request and response types, and updated the campaign path parameter to use a string directly. [1] [2] [3] [4] [5]

Route Implementation:

  • Implemented OtherCostsPatchRoute in src/routes/campaigns/campaignId/finance/otherCosts/_patch/index.ts, handling validation, updating the cost record, managing attachments (including S3 deletion), and returning the updated data. Includes detailed error handling for invalid input, missing resources, and server errors.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Tests difference:

New Tests

< Authentication and Authorization - Should allow access with admin permissions
< Authentication and Authorization - Should allow access with olp permissions for the campaign
< Authentication and Authorization - Should return 403 if user has olp permissions for different campaign
< Authentication and Authorization - Should return 403 if user is not admin and does not have olp permissions
< Authentication and Authorization - Should return 403 if user is not logged in
< Error Handling - Should return 500 if S3 deletion fails
< Input Validation - Should return 400 if attachments array item is missing mime_type
< Input Validation - Should return 400 if attachments array item is missing url
< Input Validation - Should return 400 if attachments is missing
< Input Validation - Should return 400 if cost is missing
< Input Validation - Should return 400 if cost_id is missing
< Input Validation - Should return 400 if cost_id is negative
< Input Validation - Should return 400 if cost_id is null
< Input Validation - Should return 400 if cost_id is zero
< Input Validation - Should return 400 if description is missing
< Input Validation - Should return 400 if supplier_id is missing
< Input Validation - Should return 400 if type_id is missing
< Resource Validation - Should return 404 if cost belongs to another campaign
< Resource Validation - Should return 404 if cost_id does not exist
< Resource Validation - Should return 404 if supplier_id does not exist
< Resource Validation - Should return 404 if type_id does not exist
< Success - admin permissions - Should delete multiple old attachments from S3 when updating
< Success - admin permissions - Should delete old attachments from S3 when updating
< Success - admin permissions - Should only update specified cost, not others
< Success - admin permissions - Should update cost and replace attachments
< Success - admin permissions - Should update cost in database
< Success - admin permissions - Should update cost with empty attachments array
< Success - admin permissions - Should update cost without old attachments
< Success - olp permissions - Should update cost and replace attachments with olp permissions
< Success - olp permissions - Should update cost with olp permissions

@Kariamos Kariamos merged commit 37ba13e into UN-2274-other-costs Feb 3, 2026
4 checks passed
@Kariamos Kariamos deleted the patch-other-costs branch February 3, 2026 08:58
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.

2 participants