Skip to content
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

Add Expiry Date on Receive Line Item #8867

Merged

Conversation

jacobfelknor
Copy link
Contributor

Addresses #6176

Add option in PUI receive line item form for adding an expiry.
Update test PurchaseOrderReceive.test_valid to include an expiry_date

Copy link

netlify bot commented Jan 9, 2025

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 1bbc97c
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/6782bbe97a97260008c84c57
😎 Deploy Preview https://deploy-preview-8867--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 86 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@jacobfelknor
Copy link
Contributor Author

weird - my pre-commit checks passed locally, but fail in actions. Any suggestions?

@matmair matmair added enhancement This is an suggested enhancement or new feature order Related to purchase orders / sales orders labels Jan 10, 2025
@matmair matmair added this to the 1.0.0 milestone Jan 10, 2025
@matmair
Copy link
Member

matmair commented Jan 10, 2025

Thank you for implementing this @jacobfelknor!
Loogs good in general. Due to the change in the API response you will need to bump the api version in api_version.py - and provide a short description in the text block (including a link to this PR). The changes in the API schema are visible in the CI - https://github.com/jacobfelknor/InvenTree/actions/runs/12701501246/job/35406119149#step:10:30

Regarding the pre-cmmit issue: not really sure what caused it - could also not get it to change anything on my setup. I simply reset that file for now to keep this PR going. Dependencies tend to be difficult in a lot of surprising ways.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.

Project coverage is 84.99%. Comparing base (dcff7a5) to head (1bbc97c).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
src/frontend/src/forms/PurchaseOrderForms.tsx 45.45% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8867      +/-   ##
==========================================
- Coverage   85.23%   84.99%   -0.25%     
==========================================
  Files        1177     1177              
  Lines       51804    52221     +417     
  Branches     2094     2101       +7     
==========================================
+ Hits        44156    44386     +230     
- Misses       7119     7310     +191     
+ Partials      529      525       -4     
Flag Coverage Δ
backend 86.98% <100.00%> (+<0.01%) ⬆️
pui 69.33% <45.45%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SchrodingersGat
Copy link
Member

SchrodingersGat commented Jan 10, 2025

@jacobfelknor nice work, implementation looks very clean!

Functionality

Tested it locally, seems to work very nicely indeed!

Unit Testing

I have made some suggestions to tweak two of the changed code lines which will fix the CI issues. An "empty" date must be None - not an empty string

Default Values

When specifying the "expiry date" via the UI form - it would be useful to pull out the "default value" from the part information.

This is stored in the default_expiry field for the associated part - and should be available via the API

Hidden if Disabled

For the UI side of things, please ensure that the UI elements are hidden if the STOCK_ENABLE_EXPIRY global setting is disabled. There are multiple examples in the existing frontend code showing how to use the useGlobalSettingsState hook to check this

@jacobfelknor
Copy link
Contributor Author

Sounds good, I will work on these changes now

const [expiryDateOpen, expiryDateHandlers] = useDisclosure(false, {
onOpen: () => {
// check the default part expiry. Assume expiry is relative to today
const defaultExpiry = record.part_detail?.default_expiry;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am assuming the number of days specified in default_expiry should be relative to the receive date.

I'm not well-versed in formatting javascript dates... but coming from Python this doesn't feel great. Open to suggestion here if there is a better way

Copy link
Member

Choose a reason for hiding this comment

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

Could it be as simple as adding N days to the current date, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes... that is what I'm doing... but the formatting is what gets so verbose (lines 311-314). Does the form require me to format it in "YYYY-MM-DD"?

Copy link
Member

Choose a reason for hiding this comment

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

We already have dayjs dependency in the frontend code, so you could do something like:

// Generate a date 10 days in the future
const futureDate = dayjs().add(10, 'day').format('YYYY-MM-DD');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like that much better. Thanks for the tip. Updated

@SchrodingersGat
Copy link
Member

@jacobfelknor thanks for the great work here :)

@SchrodingersGat SchrodingersGat merged commit e8c1417 into inventree:master Jan 12, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an suggested enhancement or new feature order Related to purchase orders / sales orders
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants