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

Handle different payments with same transaction id #124

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

annttu
Copy link
Contributor

@annttu annttu commented Oct 10, 2016

Fix situation where two different payments from different years have same transaction id but different reference numbers and/or messages.
CSV exports from Procountor have transaction id without year thus making duplicate transaction ids from different years possible.
Also fixes transaction id field length (ref. finanssiala.fi )

@joneskoo
Copy link
Contributor

Any idea why tests fail? I couldn't see the obvious reason why the helper wouldn't work in this test but works in others.

Copy link
Contributor

@joneskoo joneskoo left a comment

Choose a reason for hiding this comment

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

At least the test needs some fixes. I'd like to hear some reasoning for the unique_together set.

@@ -179,7 +179,10 @@ def _get_row(self, row):

def row_to_payment(row):
try:
p = Payment.objects.get(transaction_id__exact=row['transaction'])
# Search first for from already imported rows
Copy link
Contributor

Choose a reason for hiding this comment

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

Search first for from already imported rows

@@ -179,7 +179,10 @@ def _get_row(self, row):

def row_to_payment(row):
try:
p = Payment.objects.get(transaction_id__exact=row['transaction'])
# Search first for from already imported rows
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a comment here csvbills#L112-L122 BillDictReader.next() that row_to_payment is sensitive to changes in the data cleaning done in the next function?

Meaning if something was imported with old version, this would fail in later version as the normalization will be different.

@@ -933,7 +933,7 @@ class Meta:
permissions = (
("can_import_payments", "Can import payment data"),
)

unique_together = ('reference_number', 'transaction_id', 'message')
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the original issue description, I'd have thought it'd be better to unique transaction_id and payment_day, not reference number and message?

I don't know why we have payment_day is a DateTimeField, and not just a date, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is true, fixed in newest commit.

error = "The sample file should have contained only one payment"
self.assertEqual(Payment.objects.count(), 1, error)
with open(data_file("procountor-csv-single.csv"), 'r') as f:
process_procountor_csv(f)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for doing this twice on the same input file? Should this be two tests?

membership/tests.py Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Nov 10, 2018

Codecov Report

Merging #124 into master will increase coverage by 0.15%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #124      +/-   ##
==========================================
+ Coverage   74.67%   74.83%   +0.15%     
==========================================
  Files          53       54       +1     
  Lines        5173     5205      +32     
==========================================
+ Hits         3863     3895      +32     
  Misses       1310     1310
Impacted Files Coverage Δ
membership/models.py 80.54% <100%> (+0.02%) ⬆️
membership/tests.py 98.13% <100%> (+0.03%) ⬆️
membership/migrations/0006_auto_20161010_0854.py 100% <100%> (ø)
membership/management/commands/csvbills.py 91.46% <100%> (+0.6%) ⬆️
...mbership/management/commands/generate_test_data.py 90.47% <0%> (-0.8%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9bfdb40...47271b0. Read the comment docs.

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.

None yet

3 participants