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

Feature MobilePay transaction integration #204

Merged
merged 80 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
5ae86ef
[paytool] Add charfield for transactions to member model
falkecarlsen Sep 8, 2020
91398e3
[paytool] Add paytool to url pattern and add WIP handler
falkecarlsen Sep 8, 2020
54ab6cc
[paytool] Add paytool template
falkecarlsen Sep 8, 2020
4cd50b4
[paytool] Increment: Rework of old batch, presents nicely and does up…
falkecarlsen Sep 8, 2020
1f48acf
[paytool] Increment: Add MobilePayment model, parsing, and WIP-changes
falkecarlsen Sep 10, 2020
f88bf02
[paytool] Add test fixtures for mobilepay testing
falkecarlsen Sep 12, 2020
193ed86
[paytool] Add path fix of script and auth user for fixture
falkecarlsen Sep 12, 2020
6447d07
[paytool] Add distinct CSV uploader and working paytool
falkecarlsen Sep 13, 2020
f419b6f
[paytool] Add charfield for transactions to member model
falkecarlsen Sep 8, 2020
a3272f8
[paytool] Add paytool to url pattern and add WIP handler
falkecarlsen Sep 8, 2020
c21b7a9
[paytool] Add paytool template
falkecarlsen Sep 8, 2020
5357045
[paytool] Increment: Rework of old batch, presents nicely and does up…
falkecarlsen Sep 8, 2020
7a44346
[paytool] Increment: Add MobilePayment model, parsing, and WIP-changes
falkecarlsen Sep 10, 2020
a2d6270
[paytool] Add test fixtures for mobilepay testing
falkecarlsen Sep 12, 2020
97f093e
[paytool] Add path fix of script and auth user for fixture
falkecarlsen Sep 12, 2020
676ca95
[paytool] Add distinct CSV uploader and working paytool
falkecarlsen Sep 13, 2020
f1ed2f9
Merge branch 'feature-mobilepaytool' of https://github.com/cogitantiu…
falkecarlsen Sep 13, 2020
ff74ba0
[paytool] Fix MobilePay timestamp and refactor csv import function
falkecarlsen Sep 13, 2020
ece3c41
[paytool] Fix duplicated code in *PaymentAdmin
falkecarlsen Sep 13, 2020
cde0147
[paytool] Add unique constraint on Payment foreign key to MobilePayme…
falkecarlsen Sep 17, 2020
675d130
[paytool] Clean up display of CSV imports
falkecarlsen Sep 17, 2020
280fd40
[paytool] Fix django-select2 usage in paytool
falkecarlsen Sep 18, 2020
d9ccedb
[paytool] Restrict MobilePayment matching to active users
falkecarlsen Sep 18, 2020
d7ce413
[paytool] Make member matching case insensitive
falkecarlsen Sep 18, 2020
9085e22
[paytool] Add association of admin user on approved MobilePayment
falkecarlsen Sep 21, 2020
3dbf5f6
[paytool] Add formatted view of amount
falkecarlsen Sep 21, 2020
480062a
[paytool] Add back admin user in fixture
falkecarlsen Sep 24, 2020
464c4f3
[paytool] Refactor feature
falkecarlsen Sep 26, 2020
09b9365
[paytool] Add logging of MobilePayment action
falkecarlsen Sep 26, 2020
90345e0
[paytool] Refactor query into utils and remove unused data in paytool…
falkecarlsen Sep 26, 2020
72362bd
[paytool] Refine user-text in mobilepaytool
falkecarlsen Sep 26, 2020
a535648
[paytool] Fix py36 datetime.fromisoformat function missing
falkecarlsen Sep 26, 2020
38ab417
[paytool] Add ignore-functionality for MobilePayment processing
falkecarlsen Sep 26, 2020
9444d3a
[paytool] Add general tests
falkecarlsen Sep 26, 2020
d9900d8
[paytool] Add batch and ignored MobilePayment tests
falkecarlsen Sep 26, 2020
de71569
[paytool] Refactor timestamp conversion during import
falkecarlsen Sep 26, 2020
9161703
[paytool] Remove approved_by_admin-field anticipating PR #207
falkecarlsen Sep 26, 2020
da2319d
[paytool] Add min-width to select2 box on paytool
falkecarlsen Sep 27, 2020
4c8feeb
[paytool] Add named migration for feature
falkecarlsen Sep 27, 2020
f6caadc
[paytool] Add member-guess functionality and related tests
falkecarlsen Sep 27, 2020
de81906
[paytool] Update testdata and add application of member-guess on appr…
falkecarlsen Sep 27, 2020
53bdc3c
[paytool] Refactor datetime parsing to using Django's own util
falkecarlsen Oct 2, 2020
40a876a
[paytool] Remove old datetime parsing artifacts
falkecarlsen Oct 2, 2020
b27034c
[paytool] Merge mobilepay import and paytool into one page
falkecarlsen Oct 2, 2020
2974470
[timezone] Use status-choice and improve form
falkecarlsen Oct 9, 2020
061ef43
Improve submission of processed mobilepayments and refine form
falkecarlsen Oct 27, 2020
4c95733
Update testdata-mobilepay.json for status field change
falkecarlsen Oct 27, 2020
07bbac8
Remove Mobilepay Django reload script
falkecarlsen Oct 27, 2020
213d746
Undo automatic reformatting
falkecarlsen Oct 27, 2020
6e88175
Add PaymentAdmin flag for assoc with MobilePayment
falkecarlsen Oct 28, 2020
cb98e75
Fix import and add missing comment
falkecarlsen Oct 28, 2020
9822b64
Add multiple_csv_submission test
falkecarlsen Oct 28, 2020
d7d5cd2
Remove autoformatting - again
falkecarlsen Oct 28, 2020
6c4ab2e
Moves duplicated styles into class
asger-weirsoee Oct 30, 2020
8ebb003
Add custom widget and optimize admin code
hrjakobsen Nov 2, 2020
37b3192
Move ReadOnlyFemberInput to templates/admin and add italics
falkecarlsen Nov 2, 2020
e366b22
Add mobilepay integration (#1)
joandrsn Nov 4, 2020
26d6438
Add Mobilepay API to MobilePaytool with fixes
falkecarlsen Nov 4, 2020
bf14f76
Rework frontend design
falkecarlsen Nov 4, 2020
1a99fdc
Add undo functionality to MobilePayments with tests and django batch-…
falkecarlsen Nov 5, 2020
d3a6f2b
Restric member_guess to active users
falkecarlsen Nov 5, 2020
29dce7f
Add desc sorted timestamp to mobilepaytool and remove customer_name
falkecarlsen Nov 5, 2020
1021ede
Rename url for mobilepaytool and reformat ReadonlyFemberInput
falkecarlsen Nov 6, 2020
01e4f5c
Fix admin-index url and use unified .select2 css
falkecarlsen Nov 11, 2020
2e318d1
Fix dropdown-bug in admin and allow nullable comment
falkecarlsen Nov 11, 2020
24d7c9b
Update migration to reflect comment changes
falkecarlsen Nov 11, 2020
71014c5
Clean up and fix bugs for mobilepaymentimport
falkecarlsen Nov 11, 2020
503bee1
Remove member_guess from feature
falkecarlsen Nov 13, 2020
aba0d4b
Rework utils for matching comment to member and mobilepaymentimport-c…
falkecarlsen Nov 13, 2020
9db067d
Add 'submit all matches' functionality
falkecarlsen Nov 13, 2020
890928f
Add check for submit-all-payments, some tests, and fix test fixture
falkecarlsen Nov 13, 2020
344435e
Fix submit-matched-payments bug and rework frontend
falkecarlsen Nov 13, 2020
dc0c83d
Apply suggestions from code review
falkecarlsen Nov 13, 2020
a137018
Fix indentation error
falkecarlsen Nov 13, 2020
f6e428e
Refactor CSS, polish, and cleanup
falkecarlsen Nov 14, 2020
a17176e
Add mobilepaytool.css
falkecarlsen Nov 18, 2020
5bb9fa0
Only send payment mail to fember if adding money
falkecarlsen Nov 18, 2020
8ef0a38
Merge branch 'next' into feature-mobilepaytool
falkecarlsen Nov 18, 2020
d6165c5
Recreate migration due to dangling_migration feature
falkecarlsen Nov 18, 2020
ec96922
Fix bug in processed_mobilepayment_query processing mobilepayments wi…
falkecarlsen Nov 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ MANIFEST/

.coverage
htmlcov/

# ignore mobilepay api token
stregsystem/management/commands/tokens.json
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ regex==2017.07.28
freezegun==0.3.15
Django-Select2==5.11.1
django-debug-toolbar==1.8
requests==2.24.0
qrcode==6.1
52 changes: 47 additions & 5 deletions stregsystem/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
PayTransaction,
Product,
Room,
Sale
Sale,
MobilePayment
)
from stregsystem.templatetags.stregsystem_extras import money
from stregsystem.utils import (
make_active_productlist_query,
make_inactive_productlist_query
Expand Down Expand Up @@ -222,7 +224,7 @@ def get_queryset(self):


class PaymentAdmin(admin.ModelAdmin):
list_display = ('get_username', 'timestamp', 'get_amount_display')
list_display = ('get_username', 'timestamp', 'get_amount_display', 'is_mobilepayment')
valid_lookups = ('member')
search_fields = ['member__username']
autocomplete_fields = ['member']
Expand All @@ -237,19 +239,58 @@ def get_username(self, obj):
get_username.admin_order_field = "member__username"

def get_amount_display(self, obj):
if obj.amount is None:
obj.amount = 0
return "{0:.2f} kr.".format(obj.amount / 100.0)
return money(obj.amount)

get_amount_display.short_description = "Amount"
get_amount_display.admin_order_field = "amount"


def is_mobilepayment(self, obj):
return MobilePayment.objects.filter(payment=obj.pk).exists()

is_mobilepayment.short_description = "From MobilePayment"
is_mobilepayment.admin_order_field = "from_mobilepayment"
is_mobilepayment.boolean = True


class MobilePaymentAdmin(admin.ModelAdmin):
list_display = (
'payment', 'customer_name', 'comment', 'timestamp', 'transaction_id', 'get_amount_display', 'status')
valid_lookups = 'member'
search_fields = ['member__username']
autocomplete_fields = ['member', 'payment']

class Media:
css = {'all': ('stregsystem/select2-stregsystem.css',)}

def get_amount_display(self, obj):
return money(obj.amount)

get_amount_display.short_description = "Amount"
get_amount_display.admin_order_field = "amount"

# django-bug, .delete() is not called https://stackoverflow.com/questions/1471909/django-model-delete-not-triggered
actions = ['really_delete_selected']

def get_actions(self, request):
actions = super(MobilePaymentAdmin, self).get_actions(request)
del actions['delete_selected']
return actions

def really_delete_selected(self, _, queryset):
for obj in queryset:
obj.delete()

really_delete_selected.short_description = "Delete and refund selected entries"


class LogEntryAdmin(admin.ModelAdmin):
date_hierarchy = 'action_time'
list_filter = ['content_type', 'action_flag']
search_fields = ['object_repr', 'change_message', 'user__username']
list_display = ['action_time', 'user', 'content_type', 'object_id', 'action_flag', 'change_message', 'object_repr']


def has_view_permission(self, request, obj=None):
return request.user.is_superuser

Expand All @@ -272,3 +313,4 @@ def has_delete_permission(self, request, obj=None):
admin.site.register(Product, ProductAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Room)
admin.site.register(MobilePayment, MobilePaymentAdmin)
7 changes: 7 additions & 0 deletions stregsystem/fixtures/mobilepay-sales-testdata-fixture.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Event;Currency;Amount;Date and time;Customer name;MP-number;Comment;TransactionID;Payment point;MyShop-Number;Date;Time
Payment;DKK;69,69;2019-11-29T13:51:08.8574424+01:00;Martin Larsen;xxxx 4926;"mlarsen indbetalt ";156E027485173228;F-klubben - Stregsystemet;90601;2019-11-29;13.51.08
Payment;DKK;500,00;2019-11-28T17:40:55.7194894+01:00;Bobby Tables;xxxx 4215;tables eksdee;232E027452733666;F-klubben - Stregsystemet;90601;2019-11-28;17.40.55
Payment;DKK;200,00;2019-11-28T15:30:58.3578294+01:00;Karl Marx;xxxx 8116;marx;241E027449465355;F-klubben - Stregsystemet;90601;2019-11-28;15.30.58
Payment;DKK;500,00;2019-11-28T17:40:55.7194894+01:00;Bobby Tables;xxxx 4215;tables eksdee;232E027452733676;F-klubben - Stregsystemet;90601;2019-11-28;17.40.55
Payment;DKK;150,00;2019-11-27T12:15:38.5290119+01:00;John Doe;xxxx 7656;jdoe;016E027417049990;F-klubben - Stregsystemet;90601;2019-11-27;12.15.38
Payment;DKK;200,00;2019-11-26T12:54:37.5216501+01:00;Tester Testsen;xxxx 4215;tester;207E027395896809;F-klubben - Stregsystemet;90601;2019-11-26;12.54.37
Loading