fix
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
from decimal import Decimal
|
||||
|
||||
import requests
|
||||
from django.core.management import BaseCommand
|
||||
@@ -22,25 +23,18 @@ class Command(BaseCommand):
|
||||
with open(file_path, 'r') as f:
|
||||
data = json.load(f)
|
||||
|
||||
total_price = 0
|
||||
paid_amount = 0
|
||||
calculated_amount = 0
|
||||
must_pay_amount = 0
|
||||
count = 0
|
||||
party_not = 0
|
||||
party_number = []
|
||||
for item in data['data']['data']:
|
||||
if item['currency']['symbol'] == 'UZS':
|
||||
total_price += item['total_amount']
|
||||
paid_amount += item['paid_amount']
|
||||
calculated_amount += item['calculated_amount']
|
||||
must_pay_amount += item['must_pay_amount']
|
||||
party = Party.objects.filter(number=item['id']).first()
|
||||
# print(item['id'])
|
||||
party = Party.objects.filter(number=item['id']).first() # party_amount__calculated_amount=item['calculated_amount']).first()
|
||||
if party:
|
||||
party.party_amount.total_price = total_price
|
||||
party.party_amount.calculated_amount = calculated_amount
|
||||
party.party_amount.paid_amount = paid_amount
|
||||
party.party_amount.payment_amount = must_pay_amount
|
||||
party.party_amount.save()
|
||||
party.save()
|
||||
print(total_price)
|
||||
print(calculated_amount)
|
||||
print(paid_amount)
|
||||
print(must_pay_amount)
|
||||
if party.party_amount.calculated_amount != item['calculated_amount']:
|
||||
print(f"Party number: {party.number}: {party.party_amount.calculated_amount} -> {item['calculated_amount']}")
|
||||
party.party_amount.calculated_amount = Decimal(item['calculated_amount'])
|
||||
party.party_amount.save()
|
||||
count += 1
|
||||
print(count)
|
||||
print(party_not)
|
||||
# print(party_number)
|
||||
|
||||
Reference in New Issue
Block a user