-
-
Notifications
You must be signed in to change notification settings - Fork 301
Add purchase price per month to item details #1206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add purchase price per month to item details #1206
Conversation
WalkthroughBackend now includes a calculated PurchasePricePerMonth on item responses; frontend types, locale, and the item details view were updated to accept and render this new monthly purchase-price field. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Security Recommendations
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)backend/**/*.go📄 CodeRabbit inference engine (.github/instructions/code.instructions.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-12-29T16:29:27.462ZApplied to files:
🧬 Code graph analysis (1)backend/internal/data/repo/repo_items.go (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
backend/internal/data/ent/item.gois excluded by!backend/internal/data/ent/**
📒 Files selected for processing (4)
backend/internal/data/repo/repo_items.gofrontend/lib/api/types/data-contracts.tsfrontend/locales/en.jsonfrontend/pages/item/[id]/index.vue
🧰 Additional context used
📓 Path-based instructions (10)
frontend/**/*.{ts,tsx,vue,js,jsx}
📄 CodeRabbit inference engine (.github/instructions/code.instructions.md)
Frontend TypeScript/Vue code must pass ESLint with a maximum of 1 warning in CI (
pnpm run lint:ci)
Files:
frontend/pages/item/[id]/index.vuefrontend/lib/api/types/data-contracts.ts
frontend/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (.github/instructions/code.instructions.md)
Frontend code must pass TypeScript type checking with
task ui:checkbefore PR submission
Files:
frontend/pages/item/[id]/index.vuefrontend/lib/api/types/data-contracts.ts
frontend/pages/**/*.vue
📄 CodeRabbit inference engine (.github/instructions/code.instructions.md)
Page components must use file-based routing conventions in
frontend/pages/directoryPages in
pages/automatically become routes via file-based routing. Use square brackets for dynamic segments (e.g.,[id].vuefor:idroute parameter)
Files:
frontend/pages/item/[id]/index.vue
frontend/**/*.{vue,ts,tsx}
📄 CodeRabbit inference engine (.github/instructions/code.instructions.md)
Use Tailwind CSS utility classes for styling in Vue components instead of custom CSS
Files:
frontend/pages/item/[id]/index.vuefrontend/lib/api/types/data-contracts.ts
frontend/{components,pages,layouts}/**/*.vue
📄 CodeRabbit inference engine (.github/instructions/frontend.instructions.md)
frontend/{components,pages,layouts}/**/*.vue: Use<script setup lang="ts">for all Vue component files with TypeScript
Use Tailwind CSS for styling Vue components
Files:
frontend/pages/item/[id]/index.vue
frontend/{components,pages,composables}/**/*.{vue,ts}
📄 CodeRabbit inference engine (.github/instructions/frontend.instructions.md)
frontend/{components,pages,composables}/**/*.{vue,ts}: UseuseUserApi()composable for all API calls - provides typed, authenticated API client access
Use TypeScript types fromlib/api/types/data-contracts.tsfor API request/response objects (e.g.,ItemCreate,ItemOut)
Files:
frontend/pages/item/[id]/index.vue
frontend/{components,pages}/**/*.vue
📄 CodeRabbit inference engine (.github/instructions/frontend.instructions.md)
frontend/{components,pages}/**/*.vue: Use Shadcn-vue UI components fromcomponents/ui/for common UI elements
Use Pinia stores fromstores/for global state management (auth, preferences, etc.)
Files:
frontend/pages/item/[id]/index.vue
**/*.{ts,vue}
⚙️ CodeRabbit configuration file
**/*.{ts,vue}: Check for hardcoded strings in UI components that should be translatable.
Look for:
- String literals in Vue components (e.g. Click me)
- Alert messages, error messages, and user-facing text
- Placeholder text and labels
Files:
frontend/pages/item/[id]/index.vuefrontend/lib/api/types/data-contracts.ts
frontend/lib/api/types/**/*.ts
📄 CodeRabbit inference engine (.github/instructions/code.instructions.md)
Never manually edit generated TypeScript API types in
frontend/lib/api/types/; these are auto-generated from the backend and should be regenerated usingtask generateNever edit generated types in
lib/api/types/- they are auto-generated from backend Swagger docs. Runtask generateafter backend API changes to regenerate
Files:
frontend/lib/api/types/data-contracts.ts
backend/**/*.go
📄 CodeRabbit inference engine (.github/instructions/code.instructions.md)
Backend Go code must pass golangci-lint validation with no errors (6-minute timeout in CI)
Files:
backend/internal/data/repo/repo_items.go
🧠 Learnings (2)
📚 Learning: 2025-12-29T16:30:10.230Z
Learnt from: CR
Repo: sysadminsmedia/homebox PR: 0
File: .github/instructions/frontend.instructions.md:0-0
Timestamp: 2025-12-29T16:30:10.230Z
Learning: Applies to frontend/{components,pages,composables}/**/*.{vue,ts} : Use TypeScript types from `lib/api/types/data-contracts.ts` for API request/response objects (e.g., `ItemCreate`, `ItemOut`)
Applied to files:
frontend/lib/api/types/data-contracts.ts
📚 Learning: 2025-12-29T16:29:27.462Z
Learnt from: CR
Repo: sysadminsmedia/homebox PR: 0
File: .github/instructions/backend-internal-data.instructions.md:0-0
Timestamp: 2025-12-29T16:29:27.462Z
Learning: Use the Repository pattern for data access in `repo/` implementations with structured repository struct, input types (e.g., `ItemCreate`), output types (e.g., `ItemOut`), query types (e.g., `ItemQuery`), and mapper functions (e.g., `mapToItemOut`)
Applied to files:
backend/internal/data/repo/repo_items.go
🧬 Code graph analysis (1)
backend/internal/data/repo/repo_items.go (1)
backend/internal/data/types/date.go (1)
Date(19-19)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
- GitHub Check: End-to-End Playwright Tests / E2E Playwright Testing 4/4
- GitHub Check: Frontend Tests / Integration Tests PGSQL 17
- GitHub Check: End-to-End Playwright Tests / E2E Playwright Testing 1/4
- GitHub Check: Frontend Tests / Integration Tests PGSQL 15
- GitHub Check: End-to-End Playwright Tests / E2E Playwright Testing 3/4
- GitHub Check: Frontend Tests / Integration Tests PGSQL 16
- GitHub Check: End-to-End Playwright Tests / E2E Playwright Testing 2/4
- GitHub Check: Backend Server Tests / Go
- GitHub Check: Frontend Tests / Integration Tests
- GitHub Check: build (linux/arm64, ubuntu-24.04-arm)
- GitHub Check: build (linux/amd64, ubuntu-latest)
- GitHub Check: build (linux/amd64, ubuntu-latest)
- GitHub Check: build (linux/arm64, ubuntu-24.04-arm)
- GitHub Check: build (linux/arm64, ubuntu-24.04-arm)
- GitHub Check: build (linux/amd64, ubuntu-latest)
🔇 Additional comments (5)
frontend/locales/en.json (1)
460-460: LGTM! Translation key properly placed.The new translation key follows naming conventions and is logically positioned adjacent to the existing
purchase_priceentry.frontend/pages/item/[id]/index.vue (1)
384-388: Implementation looks correct.The new
purchasePricePerMonthdetail entry follows the same pattern as existing currency fields and properly integrates with the translation system and empty-value filtering.Note: If
purchasePricePerMonthis legitimately0(e.g., for an item purchased at no cost), it will be filtered out whenpreferences.showEmptyis false due to thefilterZeroValuescall at line 398. This behavior is consistent with other numeric fields but may hide valid zero values.backend/internal/data/repo/repo_items.go (2)
173-175: LGTM! ItemOut struct properly extended.The new
PurchasePricePerMonthfield is correctly typed asfloat64and properly placed within the Purchase section with the appropriate JSON tag.
324-324: Assignment correct, but depends on fixing the calculation.The assignment of
pppmtoPurchasePricePerMonthis correct. However, this depends on fixing the division by zero issue in the calculation logic at lines 298-305.frontend/lib/api/types/data-contracts.ts (1)
654-654: This file was auto-generated; confirm regeneration occurred viatask generate.The
purchasePricePerMonth: numberfield is correctly added to the response type as a read-only, calculated field (derived aspurchasePrice / monthsSincePurchase). It appears only in the ItemOut response contract and is not present in ItemCreate/ItemUpdate input contracts, which is the correct structure. The file header confirms auto-generation via swagger-typescript-api, and the field aligns properly with the backend implementation where it's calculated at query time, not persisted. Ensuretask generatewas run after backend schema modifications to regenerate this contract.
|
What is this trying to solve?? Sorry but I'm a bit confused on what exact situation this is trying to solve in the real world? Is it deprecating assets? Some weird subscription based hardware? I'm just not entirely sure what this solution is trying to solve. |
Valid question. The intention is indeed similar to deprecating assets. It's simply serving the curiosity on how much an item actually costs per month, especially when viewed over time. A clear value add would be in calculating on TOC, i.e. including any maintenance & costs of supply parts. |
Add 'Purchase Price per Month' to an item's details.
What type of PR is this?
What this PR does / why we need it:
Which issue(s) this PR fixes:
None. (Can surely create one if so required.)
Special notes for your reviewer:
Testing
Summary by CodeRabbit
New Features
API
Localization
✏️ Tip: You can customize this high-level summary in your review settings.