mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Add account check to migration
This commit is contained in:
parent
ce7230751e
commit
b33c3b20bb
40
migrate.py
40
migrate.py
@ -657,6 +657,35 @@ def migrate_counter():
|
|||||||
migrate_refillings()
|
migrate_refillings()
|
||||||
migrate_sellings()
|
migrate_sellings()
|
||||||
|
|
||||||
|
def check_accounts():
|
||||||
|
cur = db.cursor(MySQLdb.cursors.SSDictCursor)
|
||||||
|
cur.execute("""
|
||||||
|
SELECT *
|
||||||
|
FROM utilisateurs
|
||||||
|
""")
|
||||||
|
mde = Counter.objects.filter(id=1).first()
|
||||||
|
ae = Club.objects.filter(unix_name='ae').first()
|
||||||
|
root = User.objects.filter(id=0).first()
|
||||||
|
for r in cur:
|
||||||
|
if r['montant_compte'] and r['montant_compte'] > 0:
|
||||||
|
try:
|
||||||
|
cust = Customer.objects.filter(user__id=r['id_utilisateur']).first()
|
||||||
|
if int(cust.amount * 100) != r['montant_compte']:
|
||||||
|
print("Adding %s to %s's account" % (float(cust.amount) - (r['montant_compte']/100)))
|
||||||
|
new = Selling(
|
||||||
|
label="Ajustement migration base de donnée",
|
||||||
|
counter=mde,
|
||||||
|
club=ae,
|
||||||
|
product=None,
|
||||||
|
seller=root,
|
||||||
|
customer=cust,
|
||||||
|
unit_price=float(cust.amount) - (r['montant_compte']/100.),
|
||||||
|
quantity=1,
|
||||||
|
payment_method="SITH_ACCOUNT",
|
||||||
|
)
|
||||||
|
new.save()
|
||||||
|
except Exception as e:
|
||||||
|
print("FAIL to adjust user account: %s" % (repr(e)))
|
||||||
### Accounting
|
### Accounting
|
||||||
|
|
||||||
def migrate_accounting():
|
def migrate_accounting():
|
||||||
@ -923,15 +952,16 @@ def migrate_accounting():
|
|||||||
def main():
|
def main():
|
||||||
print("Start at %s" % start)
|
print("Start at %s" % start)
|
||||||
# Core
|
# Core
|
||||||
migrate_core()
|
# migrate_core()
|
||||||
# Club
|
# Club
|
||||||
migrate_club()
|
# migrate_club()
|
||||||
# Subscriptions
|
# Subscriptions
|
||||||
migrate_subscriptions()
|
# migrate_subscriptions()
|
||||||
# Counters
|
# Counters
|
||||||
migrate_counter()
|
# migrate_counter()
|
||||||
|
check_accounts()
|
||||||
# Accounting
|
# Accounting
|
||||||
migrate_accounting()
|
# migrate_accounting()
|
||||||
reset_index('core', 'club', 'subscription', 'accounting', 'eboutic', 'launderette', 'counter')
|
reset_index('core', 'club', 'subscription', 'accounting', 'eboutic', 'launderette', 'counter')
|
||||||
end = datetime.datetime.now()
|
end = datetime.datetime.now()
|
||||||
print("End at %s" % end)
|
print("End at %s" % end)
|
||||||
|
Loading…
Reference in New Issue
Block a user