Compare commits
No commits in common. "85568dd4f5e24770fb2e3321100aeddcc28580a7" and "580948fe1da1904ba6418daafb48a0a64824a11b" have entirely different histories.
85568dd4f5
...
580948fe1d
|
@ -1,5 +1,4 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import time
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import psycopg2 as pg
|
||||
import psycopg2.extras as pge
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import psycopg2 as pg
|
||||
import psycopg2.extras as pge
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#!/usr/env/bin python3
|
||||
import subprocess
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
import psycopg2 as pg
|
||||
import psycopg2.extras as pge
|
||||
|
@ -23,12 +21,8 @@ from note.models import Note, NoteClub
|
|||
from activity.models import Guest, GuestTransaction, Entry
|
||||
|
||||
from member.models import Membership
|
||||
from treasury.models import Remittance, SpecialTransactionProxy
|
||||
from ._import_utils import ImportCommand, BulkCreateManager, timed
|
||||
|
||||
MAP_TRANSACTION = dict()
|
||||
MAP_REMITTANCE = dict()
|
||||
|
||||
# from member/fixtures/initial
|
||||
BDE_PK = 1
|
||||
KFET_PK = 2
|
||||
|
@ -163,7 +157,7 @@ class Command(ImportCommand):
|
|||
).first().pk
|
||||
child_dict["entry_id"] = entry_id
|
||||
else:
|
||||
raise Exception(f"Guest not Found {row['id']} first_name, last_name")
|
||||
raise(f"Guest not Found {row['id']} {first_name}, last_name")
|
||||
|
||||
return obj_dict, child_dict, GuestTransaction
|
||||
|
||||
|
@ -172,7 +166,7 @@ class Command(ImportCommand):
|
|||
def import_transaction(self, cur, chunk_size, idmin):
|
||||
bulk_mgr = BulkCreateManager(chunk_size=chunk_size)
|
||||
cur.execute(
|
||||
f"SELECT t.id, t.date AS transac_date, t.type, t.emetteur,\
|
||||
f"SELECT t.date AS transac_date, t.type, t.emetteur,\
|
||||
t.destinataire,t.quantite, t.montant, t.description,\
|
||||
t.valide, t.cantinvalidate, t.categorie, \
|
||||
a.idbde, a.annee, a.wei, a.date AS adh_date, a.section\
|
||||
|
@ -185,9 +179,6 @@ class Command(ImportCommand):
|
|||
pk_transaction = 1
|
||||
for idx, row in enumerate(cur):
|
||||
self.update_line(idx, n, row["description"])
|
||||
|
||||
MAP_TRANSACTION[row["id"]] = pk_transaction
|
||||
|
||||
try:
|
||||
date = make_aware(row["transac_date"])
|
||||
except (pytz.NonExistentTimeError, pytz.AmbiguousTimeError):
|
||||
|
@ -234,8 +225,7 @@ class Command(ImportCommand):
|
|||
}
|
||||
pk_membership += 1
|
||||
pk_transaction += 1
|
||||
obj_dict, child_dict, child_transaction =\
|
||||
self._membership_transaction(row, obj_dict, child_dict, pk_membership)
|
||||
obj_dict, child_dict, child_transaction = self._membership_transaction(row, obj_dict, child_dict, pk_membership)
|
||||
# Kfet membership
|
||||
# BDE Membership
|
||||
obj_dict["pk"] = pk_transaction
|
||||
|
@ -280,51 +270,6 @@ class Command(ImportCommand):
|
|||
pk_transaction += 1
|
||||
bulk_mgr.done()
|
||||
|
||||
@timed
|
||||
@transaction.atomic
|
||||
def import_remittances(self, cur, chunk_size):
|
||||
bulk_mgr = BulkCreateManager(chunk_size=chunk_size)
|
||||
cur.execute("SELECT id, date, commentaire, close FROM remises WHERE id = 105 ORDER BY id;")
|
||||
n = cur.rowcount
|
||||
pk_remittance = 1
|
||||
|
||||
for idx, row in enumerate(cur):
|
||||
self.update_line(idx, n, row["commentaire"])
|
||||
|
||||
MAP_REMITTANCE[row["id"]] = pk_remittance
|
||||
|
||||
remittance_dict = {
|
||||
"pk": pk_remittance,
|
||||
"date": make_aware(row["date"]),
|
||||
"remittance_type_id": 1, # Only Bank checks are supported in NK15
|
||||
"comment": row["commentaire"],
|
||||
"closed": row["close"],
|
||||
}
|
||||
bulk_mgr.add(Remittance(**remittance_dict))
|
||||
|
||||
pk_remittance += 1
|
||||
|
||||
bulk_mgr.done()
|
||||
|
||||
@timed
|
||||
def import_checks(self, cur):
|
||||
cur.execute("SELECT id, nom, prenom, banque, idtransaction, idremise "
|
||||
"FROM cheques WHERE idremise = 105 ORDER BY id;")
|
||||
n = cur.rowcount
|
||||
|
||||
for idx, row in enumerate(cur):
|
||||
self.update_line(idx, n, row["nom"])
|
||||
|
||||
tr = SpecialTransactionProxy.objects.get(transaction__id=MAP_TRANSACTION[row["idtransaction"]])
|
||||
tr.remittance_id = MAP_REMITTANCE[row["idremise"]]
|
||||
tr.save()
|
||||
|
||||
tr = tr.transaction
|
||||
tr.last_name = row["nom"]
|
||||
tr.first_name = row["prenom"]
|
||||
tr.bank = row["banque"]
|
||||
tr.save()
|
||||
|
||||
@timed
|
||||
def set_roles(self):
|
||||
bulk_mgr = BulkCreateManager(chunk_size=10000)
|
||||
|
@ -352,5 +297,3 @@ class Command(ImportCommand):
|
|||
self.import_buttons(cur, kwargs["chunk"], kwargs["buttons"])
|
||||
self.import_transaction(cur, kwargs["chunk"], kwargs["transactions"])
|
||||
self.set_roles()
|
||||
self.import_remittances(cur, kwargs["chunk"])
|
||||
self.import_checks(cur)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
|
@ -19,15 +18,10 @@ class Command(BaseCommand):
|
|||
return parser
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
queryset = RecurrentTransaction.objects.filter(
|
||||
template__display=True,
|
||||
valid=True,
|
||||
created_at__gte=timezone.now() - timedelta(days=30),
|
||||
).values("template").annotate(transaction_count=Count("template")).order_by("-transaction_count")[:10]
|
||||
queryset = RecurrentTransaction.objects.filter(template__display=True, created_at__gte=timezone.now() - timedelta(days=30)).values("template").annotate(transaction_count=Count("template")).order_by("-transaction_count")[:10]
|
||||
for d in queryset.all():
|
||||
button_id = d["template"]
|
||||
button = TransactionTemplate.objects.get(pk=button_id)
|
||||
self.stdout.write(self.style.WARNING("Highlight button {name} ({count:d} transactions)..."
|
||||
.format(name=button.name, count=d["transaction_count"])))
|
||||
self.stdout.write(self.style.WARNING("Highlight button {name} ({count:d} transactions)...".format(name=button.name, count=d["transaction_count"])))
|
||||
button.highlighted = True
|
||||
button.save()
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.apps import apps
|
||||
|
|
Loading…
Reference in New Issue