fix
This commit is contained in:
@@ -151,9 +151,9 @@ class CounterpartyBalance(BaseModel):
|
||||
total_price=models.Sum("price")
|
||||
)['total_price'] or 0
|
||||
party_amount = total_amount - paid_amount
|
||||
if expence != paid_amount:
|
||||
return (party_amount + income) - expence
|
||||
else:
|
||||
# if expence != paid_amount:
|
||||
# return (party_amount + income) - expence
|
||||
# else:
|
||||
return (total_amount + income) - expence
|
||||
|
||||
def __str__(self):
|
||||
|
||||
15457
core/apps/orders/data/party.json
Normal file
15457
core/apps/orders/data/party.json
Normal file
File diff suppressed because it is too large
Load Diff
46
core/apps/orders/management/commands/find_party.py
Normal file
46
core/apps/orders/management/commands/find_party.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import json
|
||||
|
||||
import requests
|
||||
from django.core.management import BaseCommand
|
||||
|
||||
from core.apps.accounts.models import User
|
||||
from core.apps.counterparty.models import Counterparty
|
||||
from core.apps.orders.models import Order, Party, PartyAmount
|
||||
from core.apps.orders.utils.parse_date import parse_date
|
||||
from core.apps.products.models import Product, Unity
|
||||
from core.apps.projects.models import Project, ProjectFolder
|
||||
from core.apps.wherehouse.models import WhereHouse
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("file_path", type=str)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
file_path = options['file_path']
|
||||
|
||||
with open(file_path, 'r') as f:
|
||||
data = json.load(f)
|
||||
|
||||
total_price = 0
|
||||
paid_amount = 0
|
||||
calculated_amount = 0
|
||||
must_pay_amount = 0
|
||||
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()
|
||||
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)
|
||||
Reference in New Issue
Block a user