fix payment
This commit is contained in:
1 parent
4f7486152c
commit
bb3ddd1610
47 files changed
+2137
-51
No files matched your search
@@ -0,0 +1,17 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def normalize_existing_identifiers(apps, schema_editor):
|
||||
digit_map = str.maketrans('۰۱۲۳۴۵۶۷۸۹٠١٢٣٤٥٦٧٨٩', '01234567890123456789')
|
||||
for name in ('PaymentNotice', 'PaymentReceiptRevision'):
|
||||
records = apps.get_model('payments', name).objects.using(schema_editor.connection.alias)
|
||||
for pk, original in records.exclude(deposit_id='').values_list('pk', 'deposit_id').iterator(chunk_size=500):
|
||||
value = original.translate(digit_map).strip()
|
||||
normalized = (value.lstrip('0') or '0') if value else ''
|
||||
if normalized != original:
|
||||
records.filter(pk=pk).update(deposit_id=normalized)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [('payments', '0005_paymentnotice_deleted_at')]
|
||||
operations = [migrations.RunPython(normalize_existing_identifiers, migrations.RunPython.noop)]
|
||||
Reference in new issue
Block a user