diff --git a/src/reference/openapi.yml b/src/reference/openapi.yml index bc88cae91..91c079801 100644 --- a/src/reference/openapi.yml +++ b/src/reference/openapi.yml @@ -13462,6 +13462,8 @@ paths: application/json: schema: type: object + required: + - items properties: items: type: array @@ -13471,6 +13473,13 @@ paths: x-stoplight: id: srl106ylr6cpm type: object + required: + - cost_id + - type + - supplier + - description + - attachments + - cost properties: cost_id: type: number @@ -13480,6 +13489,9 @@ paths: type: object x-stoplight: id: itchthltx575n + required: + - name + - id properties: name: type: string @@ -13493,6 +13505,9 @@ paths: type: object x-stoplight: id: pewi2gjqq2j1h + required: + - name + - id properties: name: type: string @@ -13514,6 +13529,10 @@ paths: x-stoplight: id: w31uej26rl532 type: object + required: + - id + - url + - mimetype properties: id: type: number @@ -13527,6 +13546,10 @@ paths: type: string x-stoplight: id: 6tqj2cg96280v + cost: + type: number + x-stoplight: + id: 4zut3xli3ht5f examples: Example 1: value: @@ -13543,6 +13566,7 @@ paths: url: string mimetype: string cost_id: 0 + cost: 10.2 '403': description: Forbidden '404': diff --git a/src/routes/campaigns/campaignId/finance/otherCosts/_get/index.spec.ts b/src/routes/campaigns/campaignId/finance/otherCosts/_get/index.spec.ts index a575d52b6..b475ade8a 100644 --- a/src/routes/campaigns/campaignId/finance/otherCosts/_get/index.spec.ts +++ b/src/routes/campaigns/campaignId/finance/otherCosts/_get/index.spec.ts @@ -161,6 +161,7 @@ describe("GET /campaigns/campaignId/finance/otherCosts", () => { items: expect.arrayContaining([ expect.objectContaining({ cost_id: 1, + cost: 100.5, type: { name: "Type 1", id: 1, @@ -185,6 +186,7 @@ describe("GET /campaigns/campaignId/finance/otherCosts", () => { }), expect.objectContaining({ cost_id: 2, + cost: 200.75, type: { name: "Type 2", id: 2, @@ -218,6 +220,7 @@ describe("GET /campaigns/campaignId/finance/otherCosts", () => { items: expect.arrayContaining([ expect.objectContaining({ cost_id: 1, + cost: 100.5, type: { name: "Type 1", id: 1, @@ -230,6 +233,7 @@ describe("GET /campaigns/campaignId/finance/otherCosts", () => { }), expect.objectContaining({ cost_id: 2, + cost: 200.75, type: { name: "Type 2", id: 2, @@ -300,6 +304,7 @@ describe("GET /campaigns/campaignId/finance/otherCosts", () => { (item: any) => item.cost_id === 10 ); expect(costWithoutAttachments).toBeDefined(); + expect(costWithoutAttachments.cost).toBe(50); expect(costWithoutAttachments.attachments).toEqual([]); }); }); diff --git a/src/routes/campaigns/campaignId/finance/otherCosts/_get/index.ts b/src/routes/campaigns/campaignId/finance/otherCosts/_get/index.ts index e3d48bd92..8234403fd 100644 --- a/src/routes/campaigns/campaignId/finance/otherCosts/_get/index.ts +++ b/src/routes/campaigns/campaignId/finance/otherCosts/_get/index.ts @@ -6,6 +6,7 @@ import OpenapiError from "@src/features/OpenapiError"; type OtherCost = { cost_id: number; + cost: number; type: { name: string; id: number; @@ -52,7 +53,8 @@ export default class OtherCostsRoute extends CampaignRoute<{ .as("cost_id"), "description", "type_id", - "supplier_id" + "supplier_id", + "cost" ) .where("campaign_id", this.cp_id); @@ -84,6 +86,7 @@ export default class OtherCostsRoute extends CampaignRoute<{ return { cost_id: cost.cost_id, + cost: cost.cost, type: { name: type?.name || "", id: type?.id || 0, diff --git a/src/schema.ts b/src/schema.ts index b1f835100..3d6b88bdc 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -5638,22 +5638,23 @@ export interface operations { 200: { content: { "application/json": { - items?: { - cost_id?: number; - type?: { - name?: string; - id?: number; + items: { + cost_id: number; + type: { + name: string; + id: number; }; - supplier?: { - name?: string; - id?: number; + supplier: { + name: string; + id: number; }; - description?: string; - attachments?: { - id?: number; - url?: string; - mimetype?: string; + description: string; + attachments: { + id: number; + url: string; + mimetype: string; }[]; + cost: number; }[]; }; };