-
Notifications
You must be signed in to change notification settings - Fork 26
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
Sj fulfillment validation #569
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
48e9232
fixing datepickers and adding validation for fulfillments [#121151391]
Stuart-Johnson 8d869ce
Merge branch 'master' into sj_fulfillment_validation
Stuart-Johnson 5cfb22a
fixing specs [#121151391]
Stuart-Johnson c255523
oops [#121151391]
Stuart-Johnson b8694ab
Update en.yml
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,9 @@ class Fulfillment < ActiveRecord::Base | |
attr_accessible :unit_quantity | ||
attr_accessible :quantity_type | ||
attr_accessible :unit_type | ||
attr_accessible :formatted_date | ||
# attr_accessible :formatted_date | ||
|
||
validates :date, presence: true | ||
|
||
validates :time, format: { with: /\A\d+(?:\.\d{0,2})?\z/, | ||
message: 'cannot be a decimal with more than two places after the decimal point. Correct format: "1.23"' }, | ||
|
@@ -47,16 +49,16 @@ class Fulfillment < ActiveRecord::Base | |
UNIT_TYPES = ['N/A', 'Each', 'Sample', 'Aliquot', '3kg unit'] | ||
|
||
def date=(date_arg) | ||
write_attribute(:date, Time.strptime(date_arg, "%m-%d-%Y")) if date_arg.present? | ||
write_attribute(:date, Time.strptime(date_arg, "%m/%d/%Y")) if date_arg.present? | ||
end | ||
|
||
def formatted_date | ||
format_date self.date | ||
end | ||
# def formatted_date | ||
# format_date self.date | ||
# end | ||
|
||
def formatted_date=(date) | ||
self.date = parse_date(date) | ||
end | ||
# def formatted_date=(date) | ||
# self.date = parse_date(date) | ||
# end | ||
|
||
def within_date_range? start_date, end_date | ||
date = self.date.try(:to_date) | ||
|
@@ -72,15 +74,15 @@ def within_date_range? start_date, end_date | |
|
||
private | ||
|
||
def format_date(date) | ||
date.try(:strftime, '%-m/%d/%Y') | ||
end | ||
|
||
def parse_date(str) | ||
begin | ||
Date.strptime(str.to_s.strip, '%m/%d/%Y').strftime("%m-%d-%Y") | ||
rescue ArgumentError => e | ||
nil | ||
end | ||
end | ||
# def format_date(date) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove me |
||
# date.try(:strftime, '%-m/%d/%Y') | ||
# end | ||
|
||
# def parse_date(str) | ||
# begin | ||
# Date.strptime(str.to_s.strip, '%m/%d/%Y').strftime("%m-%d-%Y") | ||
# rescue ArgumentError => e | ||
# nil | ||
# end | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,9 +325,9 @@ en: | |
edit: " Edit Fulfillment" | ||
delete: " Delete Fulfillment" | ||
form: | ||
date: "Fulfillment Date:" | ||
time: "Quantity:" | ||
time_unit: "Qty Type:" | ||
date: "Fulfillment Date: *" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Everywhere else in the application we put the '*' directly after the ':' i.e. Fulfillment Date:* |
||
time: "Quantity: *" | ||
time_unit: "Qty Type: *" | ||
|
||
################ | ||
# LINE ITEMS # | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Remove me