-
Notifications
You must be signed in to change notification settings - Fork 58
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
Moving Account.amount
to Account.credit
& Account.debit
#133
Conversation
…count.credit & Account.debit
…count.credit & Account.debit
I would love the input of both @nitsujri and @PetrDlouhy on this. @nitsujri - I know this isn't precisely what you asked for, but what are your thoughts? @PetrDlouhy - How comfortable would be feel about deploying this kind of change (once stable) into your production environment? |
…0 adding two new currencies. This then causes migrations to be generated for currency fields with new default values.
All tests now passing 🎉🎉🎉 |
Account.amount
to Account.credit
& Account.debit
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.
Love everything about this. I won't be able to test this until August due to travels and deadlines, but in spirit, I 100% approve and happy to see it go out ahead of our team's direct testing.
@@ -155,7 +155,7 @@ def test_utility_bill(self): | |||
|
|||
# We receive the actual bill (we are moving a negative amount of money, | |||
# as this is an outgoing) | |||
self.gas_payable.transfer_to(self.cash, Money(-300, "EUR")) | |||
self.cash.transfer_to(self.gas_payable, Money(300, "EUR")) |
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.
This is incredible! I'm insanely excited to see this change right here.
I'm sure you already know this, but just stating it explicitly to be on the same page:
This is a breaking change for anyone doing RHS -> LHS, vice versa - using the current .transfer_to
. Saw that accounting_transfer_to
"effectively" replaces it which I think is 100% correct, just it's a significant change and warrants an "Upgrade to 2.0" document.
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'm very pleased to hear it! And yes, absolutely understood re upgrading. I've put these notes in the changelog. How does that seem to you?
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #133 +/- ##
==========================================
- Coverage 90.62% 89.52% -1.10%
==========================================
Files 69 69
Lines 4414 4506 +92
Branches 294 324 +30
==========================================
+ Hits 4000 4034 +34
- Misses 363 415 +52
- Partials 51 57 +6 ☔ View full report in Codecov by Sentry. |
Hi @PetrDlouhy – I'm inclined to merge this sometime soon. If you wanted to have a dramatic "I object!" moment then please do so soon (other reasoned input also very welcome) |
Would it be possible to remove the views? I believe the views are now no longer needed? Specifically migrations against any column that is part of a view becomes a pain. |
Ať first glance this seems reasonable. I don't have any direct objection. |
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.
Was able to test it on our codebase. Overall looks great after internal modifications.
Recommended changes:
- Remove views
- Leg.credit and debit
max_digits
needs to useHORDAK_MAX_DIGITS
. get_queryset
needs to swap signs based on account type.
…ved balance(raw=...).
…tabase function get_balance()
…(in case multiple legs in the same transaction point to the same account)
Done
Done
Done I'm a bit loathed to removed them as I think they may be useful, but I'm also willing to be found wrong on this. I've therefore added this warning to the docs for each view: Hordak's database views are still experimental and may change or be removed in a future version. In the mean-time, my hope is that the new way of structuring sql-heavy migrations will make this problem less onerous. |
I've also made some additional changes, in particular moving many balance calculations into annotations. I think this should help performance a lot. Once this settles we can see if something like #76 (running totals) is still required. I'll merge this soon unless anyone cries out. Let me know if you find any time for some testing @PetrDlouhy. I could always do an alpha-release if that helps at all. |
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.
debit
column still holds negative value post migration - blocking issue.
hordak_leg | ||
SET | ||
credit = CASE WHEN amount > 0 THEN amount END, | ||
debit = CASE WHEN amount < 0 THEN amount END, |
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.
Tried migrating our staging system in preps for production. Found the debit
column was holding a negative value. Same with the views.
I believe it should be flipped?
debit = CASE WHEN amount < 0 THEN -amount END,
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.
Thank you for catching this! Fixed.
A pre-release is now out as A huge thank you to @nitsujri and @PetrDlouhy for working through this with me. |
I've had a go at this this morning, and you can see the the core changes here.
Most of the lines changed are tests.
Notes:
my_leg.amount
is still available as a property on the Django model. It is now always a positive value.amount
argument when creating a Leg, a deprication warning will be shown.amount_legacy
(I.e. debits are negative) to the LegView, so it is still available atmy_leg.view.amount_legacy
Remaining Tasks
Follow-up work
I'll do this next in another PR