add support for membership, needs testing
This commit is contained in:
parent
f9bac69aad
commit
98addc1db9
|
@ -235,37 +235,39 @@ def import_transaction(cur):
|
||||||
tr = SpecialTransaction.objects.create(**obj_dict)
|
tr = SpecialTransaction.objects.create(**obj_dict)
|
||||||
if "cheques" in row["description"]:
|
if "cheques" in row["description"]:
|
||||||
MAP_IDSPECIALTRANSACTION[row["id"]] = tr
|
MAP_IDSPECIALTRANSACTION[row["id"]] = tr
|
||||||
|
|
||||||
elif ttype == "adhésion":
|
elif ttype == "adhésion":
|
||||||
montant = row["montant"]
|
montant = row["montant"]
|
||||||
m = re.search("Adhésion (\d\d\d\d)( \+ WEI)?", row["description"])
|
|
||||||
year = m.group(1)
|
|
||||||
wei = m.group(2)
|
|
||||||
if montant == 0: # old format for SoGé registration (before )
|
|
||||||
montant = 400
|
|
||||||
|
|
||||||
# Since BDE and Kfet are distinct, don't import membership transaction and use our custom transactions.
|
# Create Double membership to Kfet and Bde
|
||||||
|
# sometimes montant = 0, fees are modified accordingly.
|
||||||
bde_dict = {
|
bde_dict = {
|
||||||
"user": MAP_IDBDE[row["idbde"]],
|
"user": MAP_IDBDE[row["idbde"]],
|
||||||
"club": bde,
|
"club": bde,
|
||||||
"date_start": row["date"].date(), # Only date, not time
|
"date_start": row["date"].date(), # Only date, not time
|
||||||
"fee": 500,
|
"fee": min(500, montant)
|
||||||
}
|
}
|
||||||
kfet_dict = {
|
kfet_dict = {
|
||||||
"user": MAP_IDBDE[row["idbde"]],
|
"user": MAP_IDBDE[row["idbde"]],
|
||||||
"club": kfet,
|
"club": kfet,
|
||||||
"date_start": row["date"].date(), # Only date, not time
|
"date_start": row["date"].date(), # Only date, not time
|
||||||
"fee": montant - 500
|
"fee": max(montant - 500, 0),
|
||||||
}
|
}
|
||||||
try:
|
|
||||||
|
if row["valide"]:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
# membership save triggers MembershipTransaction creation
|
||||||
bde_membership = Membership.objects.get_or_create(**bde_dict)
|
bde_membership = Membership.objects.get_or_create(**bde_dict)
|
||||||
kfet_membership = Membership.objects.get_or_create(**kfet_dict)
|
kfet_membership = Membership.objects.get_or_create(**kfet_dict)
|
||||||
bde_membership.transaction.created_at = row["date"]
|
bde_membership.transaction.created_at = row["transac_date"]
|
||||||
|
bde_membership.transaction.description = row["description"]
|
||||||
bde_membership.transaction.save()
|
bde_membership.transaction.save()
|
||||||
kfet_membership.transaction.created_at = row["date"]
|
kfet_membership.transaction.created_at = row["transac_date"]
|
||||||
|
kfet_membership.transaction.description = row["description"] + "(Kfet)"
|
||||||
kfet_membership.transaction.save()
|
kfet_membership.transaction.save()
|
||||||
except IntegrityError as e:
|
else:
|
||||||
raise e
|
# don't create membership
|
||||||
|
MembershipTransaction.objects.create(**obj_dict)
|
||||||
elif ttype == "invitation":
|
elif ttype == "invitation":
|
||||||
m = re.search(r"Invitation (.*?) \((.*?)\)", row["description"])
|
m = re.search(r"Invitation (.*?) \((.*?)\)", row["description"])
|
||||||
if m is None:
|
if m is None:
|
||||||
|
|
Loading…
Reference in New Issue