Skip to content

Connect add cost and revenue to backend#380

Open
lyannne wants to merge 22 commits intomainfrom
connect-add-cost-and-revenue-to-backend
Open

Connect add cost and revenue to backend#380
lyannne wants to merge 22 commits intomainfrom
connect-add-cost-and-revenue-to-backend

Conversation

@lyannne
Copy link
Copy Markdown
Collaborator

@lyannne lyannne commented Mar 27, 2026

ℹ️ Issue

Closes #373

📝 Description

Write a short summary of what you added. Why is it important? Any member of C4C should be able to read this and understand your contribution -- not just your team members.

Briefly list the changes made to the code:

  1. Connected adding cost and revenue to backend (along with installments information)
  2. Added error handling & success messages for cost and revenue inputs at frontend level
  3. Made initial values for new cost and revenues blank/null instead of a default value
  4. Connected showing revenues to backend and edited component to display installments and amount
  5. Changed updateCost backend route to a put, checks for no changes as well

✔️ Verification

What steps did you take to verify your changes work? These should be clear enough for someone to be able to clone the branch and follow the steps themselves.

Provide screenshots of any new components, styling changes, or pages.

ticket_fr.mp4

Test Changes

If your new feature required some test to be changed or added to fit the new functionality or changes please document these changes here.

Changed tests for costs to align with PUT body type.

🏕️ (Optional) Future Work / Notes

Did you notice anything ugly during the course of this ticket? Any bugs, design challenges, or unexpected behavior? Write it down so we can clean it up in a future ticket!

  • POC card has a weird middle ground where stuff overflows, but Jane said she'd fix it! The goat 🐐
  • i also think the revenue backend needs some edits, which is why the build is failing, but lmk when that's fixed @prooflesben and I'll merge it into this branch

Copilot AI review requested due to automatic review settings March 27, 2026 02:08
@lyannne lyannne linked an issue Mar 27, 2026 that may be closed by this pull request
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR wires the Cash Flow “add cost” and “add revenue” flows to real backend endpoints (including revenue installments), adds frontend validation/messaging, and introduces a new NestJS/DynamoDB revenue module while updating cost update semantics.

Changes:

  • Frontend: connect cashflow CRUD calls to /cashflow-cost and /cashflow-revenue, add validation + success/error UI, and render revenue installments.
  • Backend: add cashflow-revenue controller/service/module with DynamoDB persistence + tests; update cost update route to PUT and add “no changes” short-circuit.
  • Access control: make Cash Flow page/tab admin-only.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
frontend/src/main-page/navbar/NavBar.tsx Makes Cash Flow tab admin-only in the sidebar.
frontend/src/main-page/grants/GrantPage.tsx Removes unused props/interface.
frontend/src/main-page/cash-flow/processCashflowDataEditSave.ts Updates cashflow API endpoints and adds edit/delete helpers.
frontend/src/main-page/cash-flow/processCashflowData.ts Points fetch calls to new cashflow endpoints.
frontend/src/main-page/cash-flow/components/CashSourceList.tsx Renders real cost/revenue items, including installments and delete actions.
frontend/src/main-page/cash-flow/components/CashRevenueInstallment.tsx New installment editor component for revenue creation.
frontend/src/main-page/cash-flow/components/CashEditLineItem.tsx Adds delete confirmation modal and edit-mode API.
frontend/src/main-page/cash-flow/components/CashEditCost.tsx New cost edit form wired to backend update call.
frontend/src/main-page/cash-flow/components/CashCategoryDropdown.tsx Supports controlled value + error styling for category selection.
frontend/src/main-page/cash-flow/components/CashAddRevenue.tsx Adds revenue form with installment support, validation, and backend submit.
frontend/src/main-page/cash-flow/components/CashAddCosts.tsx Adds cost form validation and backend submit.
frontend/src/main-page/cash-flow/CashFlowPage.tsx Introduces formatMoney and updates KPI calculation.
frontend/src/main-page/MainPage.tsx Restricts Cash Flow route to admins.
backend/src/revenue/types/revenue.types.ts Adds Swagger DTO for cashflow revenue payloads.
backend/src/revenue/cashflow-revenue.service.ts Implements DynamoDB-backed revenue CRUD + validation.
backend/src/revenue/cashflow-revenue.module.ts Registers revenue controller/service in Nest.
backend/src/revenue/cashflow-revenue.controller.ts Exposes guarded revenue endpoints.
backend/src/revenue/test/cashflow-revenue.service.spec.ts Adds unit tests for revenue service behavior.
backend/src/grant/grant.service.ts Re-enables grant notification creation on grant creation.
backend/src/cost/cashflow-cost.service.ts Adjusts validation and changes update to full-replace PUT semantics.
backend/src/cost/cashflow-cost.controller.ts Switches update endpoint from PATCH to PUT and removes by-type endpoint.
backend/src/cost/test/cashflow-cost.service.spec.ts Updates cost tests for PUT body semantics and no-change detection.
backend/src/cashflow/cashflow.service.ts Removes unused placeholder cashflow service.
backend/src/cashflow/cashflow.module.ts Removes unused placeholder cashflow module.
backend/src/cashflow/cashflow.controller.ts Removes unused placeholder cashflow controller.
backend/src/app.module.ts Replaces CashflowModule import with RevenueModule.
Comments suppressed due to low confidence (2)

frontend/src/main-page/cash-flow/processCashflowDataEditSave.ts:102

  • originalCostName is interpolated directly into the URL path; names containing spaces or reserved characters will break routing. Use encodeURIComponent(originalCostName) when building the request URL.
export const saveCostEdits = async (updatedCost: CashflowCost, originalCostName: string) => {
  try {
    const response = await api(`/cashflow-cost/${originalCostName}`, {
      method: "PUT",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(updatedCost),
    });

frontend/src/main-page/cash-flow/processCashflowDataEditSave.ts:136

  • Unlike createNewCost/createNewRevenue, the delete helpers don’t return a { success, error } result (they just console.log/console.error). This makes it hard for the UI to await deletion and surface failures. Consider returning a consistent result shape and letting the caller decide how to display/log errors.
export const deleteRevenue = async (revenueName: string) => {
        try {
          const response = await api(`/cashflow-revenue/${revenueName}`, {
            method: "DELETE",
            headers: {
              "Content-Type": "application/json",
            },
          });
  
          console.log("Response status:", response.status);
          console.log("Response ok:", response.ok);
  
          if (response.ok) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

DEV - Connect Add Cost to backend

5 participants