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

Transition: set now as transaction date #140

Closed
wants to merge 1 commit into from
Closed

Transition: set now as transaction date #140

wants to merge 1 commit into from

Conversation

KonstantinaStoikou
Copy link
Contributor

@KonstantinaStoikou KonstantinaStoikou commented Nov 19, 2020

Closes inveniosoftware/react-invenio-app-ils#294
Removed test_override_transaction_date since we are not supposed to override the transaction date.

@FlorianCassayre
Copy link
Member

It seems the tests were wrong too.
Maybe assert that the next datetime is strictly greater than its predecessor after a transaction? Otherwise you can always mock the dates module but it may be overkill.

@@ -172,7 +172,7 @@ def _date_fields2datetime(self, kwargs):
def before(self, loan, initial_loan, **kwargs):
"""Validate input, evaluate conditions and raise if failed."""
loan.update(kwargs)
loan.setdefault("transaction_date", arrow.utcnow())
loan["transaction_date"] = arrow.utcnow()
Copy link

Choose a reason for hiding this comment

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

Does this mean, we can not pass a pre-defined loan.transaction_date?

Copy link

@BadrAly BadrAly Nov 20, 2020

Choose a reason for hiding this comment

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

There is a use case important here:
when a library system is down and
transactions were recorded manually on excel file or whatever
we should be able to load these transactions with the correct transaction_date when the system is back up

Copy link

Choose a reason for hiding this comment

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

Checking with our PO ....

Copy link
Member

Choose a reason for hiding this comment

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

OK I see your point, and you're right. I think what we are trying to fix is the fact that whenever a loan is updated from one state to another the transaction_date will not change because there is already a value there. So normally if we move the statement loan["transaction_date"] = arrow.utcnow() before loan.update(kwargs) that should solve both problems.

Copy link
Contributor

Choose a reason for hiding this comment

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

@BadrAly the idea behind this change was to have the transaction_date set when it the transaction in the system really happened. I understand that the system might be down, but when it is back up, and the transactions are being loaded, they are happening from the system point of view on the "load" time (now, not in the past). So I see the transaction_date as a timestamp from the system point of view, not the librarian point of view.

Copy link

Choose a reason for hiding this comment

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

@kprzerwa @FlorianCassayre Thanks for your answers, I am checking with @pronguen and @iGormilhit on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kprzerwa Could the created field be viewed as this system timestamp? In a case of circulation backup, when a circulation transaction occurs, some dates will be calculated with regards to the circulation policy (ie a due date, or an overdue…) that should apply. When this loans will be loaded, setting the transaction date to the moment of the loads may cause issues. From my understanding, the transaction date is in fact something important from the librarian and the patron point of view.

At least if I understand correctly the conversation.

Copy link
Contributor

@kpsherva kpsherva Nov 23, 2020

Choose a reason for hiding this comment

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

@iGormilhit thank you for your answer.
I understand the usage of the transaction_date is a matter of interpretation, but I see your point with the created date.

When this loans will be loaded, setting the transaction date to the moment of the loads may cause issues.

Could you describe in more details what kind of issues do you mean?
We introduced this change because without it the REST API requires transaction_date to be present in the loan action payload - otherwise the transaction_date will not be updated when the transaction happens. In this case I can see that it will influence the way you use the field, so we will solve the problem in the marshmallow loaders.

@kpsherva kpsherva closed this Nov 25, 2020
@KonstantinaStoikou KonstantinaStoikou deleted the transaction-fix branch December 11, 2020 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loan start date
5 participants