-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactored billable invoice #61
Conversation
I would like to see the second commit updated so that the commit message has some description of the changes involved in "Refactored billable invoice". |
ef15ce6
to
342fb30
Compare
342fb30
to
845697b
Compare
845697b
to
e4e11a1
Compare
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.
Some small comments to make better use of _prepare
and _prepare_export
methods. Implement them in a separate commit to preserve this diff as mostly a copy paste and dedicate more subtle refactoring changes to future commits (within this PR).
The billable invoice now subclasses the Invoice base class. The computations involved in preparation, namely filtering out nonbillable projects and PIs, and validating PI names, have been moved to `util.py`. The function for applying the New-PI credit (`apply_credits_new_pi`) is also moved there, and the I/O needed to read and write out the PI file has been moved out of this functions for ease of testing.
71f8443
to
dce97da
Compare
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.
looks good, left a few questions/suggestions
dce97da
to
a2f6fef
Compare
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.
I am mostly nitpicking, but I think any method where you passed self
but didn't use it should just be a staticmethod.
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.
Some comments, but otherwise looks pretty close.
a2f6fef
to
0a08fea
Compare
Closes #64, I have refactored the billable invoice. I'll explain in more detail below, and have also have a question that I would like the professionals' opinions on.
For some context, the billable invoice performs 2 preparation steps (removing nonbillables and validating PI names) and 3 distinct steps during processing (loading the old PI file, applying the new PI credit, and then writing back the old PI file). I decided to split these steps into their own functions, and to store those functions in
util.py
, instead of making them private functions in theBillableInvoice
class.As for the test cases, I created a new test class for the billable invoice. Note that this new test case uses randomly generated values, instead of a hardcoded dataframe. I figured this would be more robust?
While writing the test case, l also had a few design questions I wanted to ask...
Considering how unsightly some of the test cases are, especially for the New PI credit, I was trying to think of ways to make the test case more organized and easier to follow. One of them was to create small test functions that would only test for one specific scenario (i.e a case for new PI, 1-month PI, overwritten entry, etc...), and to make a generator function that would that randomly generate the invoice and old-pi file (along with the expected output after they are processed) for a PI. I'm follow your opinions on whether randomized test data, instead of hardcoded data, would be better.