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