Repository: svthalia/concrexit

Issue:
Add a simple incrementing reference number to Payment Batches
### Is your feature request related to a problem? Please describe.
For bookkeeping purposes, it would be nice if payment Batches would have a simple incrementing reference number. That way, we can easily search for a batch and easily verify whether all batches are in the bookkeeping and vice versa. Currently, batches only display a non-unique description (which should stay!) and a unique but unpredictable UUID.  

### Describe the solution you'd like
Either:
- Don't use a UUID but just a regular auto-incremented PK
- Add a secondary auto-incremented unique reference number. Perhaps in the format of "TPAY-BATCH-20/21-001" or something like that.

### Motivation
It makes bookkeeping easy. 

### Describe alternatives you've considered
Registering this manually on paper

### Additional context



Discussion:
I don't think a batch necessarily needs a UUID as pk, so removing the custom field and altering the schema to use a regular AutoField has my preference.

Resolving patch:
diff --git a/website/payments/admin.py b/website/payments/admin.py
--- a/website/payments/admin.py
+++ b/website/payments/admin.py
@@ -331,6 +331,7 @@ class BatchAdmin(admin.ModelAdmin):
 
     inlines = (PaymentsInline,)
     list_display = (
+        "id",
         "description",
         "withdrawal_date",
         "start_date",
@@ -341,6 +342,7 @@ class BatchAdmin(admin.ModelAdmin):
         "processed",
     )
     fields = (
+        "id",
         "description",
         "withdrawal_date",
         "processed",
@@ -348,12 +350,14 @@ class BatchAdmin(admin.ModelAdmin):
         "total_amount",
     )
     search_fields = (
+        "id",
         "description",
         "withdrawal_date",
     )
 
     def get_readonly_fields(self, request: HttpRequest, obj: Batch = None):
         default_fields = (
+            "id",
             "processed",
             "processing_date",
             "total_amount",
@@ -381,24 +385,24 @@ def get_urls(self) -> list:
         urls = super().get_urls()
         custom_urls = [
             path(
-                "<uuid:pk>/process/",
+                "<int:pk>/process/",
                 self.admin_site.admin_view(admin_views.BatchProcessAdminView.as_view()),
                 name="payments_batch_process",
             ),
             path(
-                "<uuid:pk>/export/",
+                "<int:pk>/export/",
                 self.admin_site.admin_view(admin_views.BatchExportAdminView.as_view()),
                 name="payments_batch_export",
             ),
             path(
-                "<uuid:pk>/export-topic/",
+                "<int:pk>/export-topic/",
                 self.admin_site.admin_view(
                     admin_views.BatchTopicExportAdminView.as_view()
                 ),
                 name="payments_batch_export_topic",
             ),
             path(
-                "<uuid:pk>/topic-description/",
+                "<int:pk>/topic-description/",
                 self.admin_site.admin_view(
                     admin_views.BatchTopicDescriptionAdminView.as_view()
                 ),
diff --git a/website/payments/migrations/0014_auto_20201016_2122.py b/website/payments/migrations/0014_auto_20201016_2122.py
new file mode 100644
--- /dev/null
+++ b/website/payments/migrations/0014_auto_20201016_2122.py
@@ -0,0 +1,48 @@
+# Generated by Django 3.1.1 on 2020-10-16 19:22
+
+from django.db import migrations, models
+import django.db.models.deletion
+import payments.models
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('payments', '0013_auto_20201012_2217'),
+    ]
+
+    operations = [
+        migrations.DeleteModel(
+            name='Batch',
+        ),
+        migrations.RemoveField(
+            model_name='payment',
+            name='batch',
+        ),
+        migrations.CreateModel(
+            name='Batch',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('processed', models.BooleanField(default=False,
+                                                  verbose_name='processing status')),
+                ('processing_date', models.DateTimeField(blank=True, null=True,
+                                                         verbose_name='processing date')),
+                ('description', models.TextField(
+                    default=payments.models._default_batch_description,
+                    verbose_name='description')),
+                ('withdrawal_date', models.DateField(default=payments.models._default_withdrawal_date, verbose_name='withdrawal date')),
+            ],
+            options={
+                'verbose_name': 'batch',
+                'verbose_name_plural': 'batches',
+                'permissions': (('process_batches', 'Process batch'),),
+            },
+        ),
+        migrations.AddField(
+            model_name='payment',
+            name='batch',
+            field=models.ForeignKey(blank=True, null=True,
+                                    on_delete=django.db.models.deletion.PROTECT,
+                                    related_name='payments_set',
+                                    to='payments.batch'),
+        ),
+    ]
diff --git a/website/payments/models.py b/website/payments/models.py
--- a/website/payments/models.py
+++ b/website/payments/models.py
@@ -89,7 +89,11 @@ class Payment(models.Model):
     )
 
     batch = models.ForeignKey(
-        "Batch", models.PROTECT, related_name="payments_set", blank=True, null=True,
+        "payments.Batch",
+        models.PROTECT,
+        related_name="payments_set",
+        blank=True,
+        null=True,
     )
 
     notes = models.TextField(verbose_name=_("notes"), blank=True, null=True)
@@ -155,8 +159,6 @@ class Batch(models.Model):
     Describes a batch of payments for export
     """
 
-    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
-
     processed = models.BooleanField(verbose_name=_("processing status"), default=False,)
 
     processing_date = models.DateTimeField(


Test patch:
diff --git a/website/payments/tests/test_admin.py b/website/payments/tests/test_admin.py
--- a/website/payments/tests/test_admin.py
+++ b/website/payments/tests/test_admin.py
@@ -661,7 +661,7 @@ def test_get_readonly_fields(self) -> None:
         b = Batch.objects.create()
         self.assertCountEqual(
             self.admin.get_readonly_fields(None, b),
-            ["processed", "processing_date", "total_amount",],
+            ["id", "processed", "processing_date", "total_amount",],
         )
 
         b.processed = True
@@ -669,6 +669,7 @@ def test_get_readonly_fields(self) -> None:
         self.assertCountEqual(
             self.admin.get_readonly_fields(None, b),
             [
+                "id",
                 "description",
                 "processed",
                 "processing_date",