Skip to content

LF-5276: Save and return which crops or animals each expense is linked to models endpoints tests#4169

Open
SayakaOno wants to merge 17 commits into
integrationfrom
LF-5276/Save_and_return_which_crops_or_animals_each_expense_is_linked_to_models_endpoints_tests
Open

LF-5276: Save and return which crops or animals each expense is linked to models endpoints tests#4169
SayakaOno wants to merge 17 commits into
integrationfrom
LF-5276/Save_and_return_which_crops_or_animals_each_expense_is_linked_to_models_endpoints_tests

Conversation

@SayakaOno
Copy link
Copy Markdown
Collaborator

@SayakaOno SayakaOno commented May 11, 2026

Description

  • Add farmExpenseAnimalModel and farmExpenseCropVarietyModel
  • Update farmExpense relations
  • Add checkFarmExpense middleware for validation
    • Create crop variety model method cropVarietiesBelongToFarm
    • Extract common utility functions from checkSale
  • Update farmExpenseController to handle allocation modifications
  • Add tests
  • (Irrelevant to the ticket) Update GET response to return [] instead of 404 when there are no expenses
    • Adjust saga

PATCH sample requests:

  • Delete existing animal expense
    { "farm_expense_animal": [] }
    
    or
    { "farm_expense_animal": null }
    
    or add farm_expense_crop_variety
    { "farm_expense_crop_variety": [...] }
    

Jira link: https://lite-farm.atlassian.net/browse/LF-5276

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have ordered translation keys alphabetically (optional: run pnpm i18n to help with this)
  • I have added the GNU General Public License to all new files

SayakaOno and others added 6 commits May 11, 2026 13:24
…relations and cropVarietiesBelongToFarm

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… allocations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use .length check so PATCH can send farm_expense_animal: [] with
farm_expense_crop_variety items to transition between allocation types.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the 404 workaround in the saga now that the API consistently
returns 200 with an empty array for farms with no expenses.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SayakaOno SayakaOno self-assigned this May 11, 2026
@SayakaOno SayakaOno added the enhancement New feature or request label May 11, 2026
@SayakaOno SayakaOno changed the title [WIP] LF-5276: Save and return which crops or animals each expense is linked to models endpoints tests LF-5276: Save and return which crops or animals each expense is linked to models endpoints tests May 12, 2026
@SayakaOno SayakaOno marked this pull request as ready for review May 12, 2026 22:03
@SayakaOno SayakaOno requested review from a team as code owners May 12, 2026 22:03
@SayakaOno SayakaOno requested review from kathyavini and removed request for a team May 12, 2026 22:03
@SayakaOno SayakaOno marked this pull request as draft May 13, 2026 16:18
@SayakaOno SayakaOno marked this pull request as ready for review May 13, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant