diff --git a/app/apps/finance/models.py b/app/apps/finance/models.py index e140acb..35a7749 100644 --- a/app/apps/finance/models.py +++ b/app/apps/finance/models.py @@ -29,5 +29,6 @@ class Balance: place: str amount_balance: decimal.Decimal currency: str + percent: float account_number: str | None = None bank_name: str | None = None diff --git a/app/apps/finance/services/integration_1c/api.py b/app/apps/finance/services/integration_1c/api.py index 8c162df..03af908 100644 --- a/app/apps/finance/services/integration_1c/api.py +++ b/app/apps/finance/services/integration_1c/api.py @@ -38,11 +38,14 @@ class Finance1CAPI: amount_balance = balance_item['СуммаОстаток'] money_type = balance_item['ВидДенежныхСредств'].strip() currency_code = balance_item['Валюта'] + summary_for_obj = response_data['summary'][money_type][currency_code] + percent = amount_balance * 100 / summary_for_obj balance_object = Balance( money_type=money_type, place=balance_place, amount_balance=amount_balance, - currency=currency_code + currency=currency_code, + percent=percent ) if ',' in balance_place: mas = balance_place.split(',', maxsplit=1) diff --git a/app/apps/finance/services/integration_1c/service.py b/app/apps/finance/services/integration_1c/service.py index d3393c3..effb0e1 100644 --- a/app/apps/finance/services/integration_1c/service.py +++ b/app/apps/finance/services/integration_1c/service.py @@ -89,7 +89,7 @@ class Finance1CService(DashboardBaseService): result[money_type][balance_object['currency']]['data']['main'] = [] result[money_type][balance_object['currency']]['data']['other'] = [] - if percent > 3: + if percent > 2: result[money_type][balance_object['currency']]['data']['main'].append(balance_object) else: result[money_type][balance_object['currency']]['data']['other'].append(balance_object) diff --git a/app/apps/finance/templates/finance/fin_index.html b/app/apps/finance/templates/finance/fin_index.html index c9cf82e..0c7aaca 100644 --- a/app/apps/finance/templates/finance/fin_index.html +++ b/app/apps/finance/templates/finance/fin_index.html @@ -2,12 +2,17 @@ {% load humanize %} {% block content %} +
-
+

Остатки по счетам @@ -24,7 +29,7 @@ {{ balances.bank.156.summary|intcomma }} ¥ - + Касса
{{ balances.cash.643.summary|intcomma }} ₽ @@ -33,37 +38,51 @@

-

Более 3% от общего баланса

+

Более 2% от общего баланса

-

До 3% от общего баланса

+

До 2% от общего баланса

-

Все счета

+

Все счета

+
+
+ +
+ + +
+ Процент от баланса +
+
+ Остаток +
+
+
+
{% for balance in balances.bank.643.data.main %}
-
+
{% if balance.bank_name and balance.account_number %} {{ balance.bank_name }}: {{ balance.account_number }} {% else %} - {% if balance.place %} - {{ balance.place }} - {% else %} - Безымянный счет - {% endif %} - {% endif %} + {{ balance.place }}{% endif %} - {{ balance.amount_balance|intcomma }}₽ + {{ balance.percent|floatformat:1 }} % + + {{ balance.amount_balance|intcomma }} ₽
@@ -73,14 +92,17 @@
-
+
{% if balance.bank_name and balance.account_number %} {{ balance.bank_name }}: {{ balance.account_number }} {% else %} {{ balance.place }}{% endif %} - {{ balance.amount_balance|intcomma }}₽ + {{ balance.percent|floatformat:3 }} % + + {{ balance.amount_balance|intcomma }} ₽
@@ -126,22 +148,39 @@
-

Более 1% от общего долга

+

Более 1% от общего долга

- Общая дебиторская задолженность по покупателям + Общая задолженность по покупателям
Долг: {{ debts.buyers.summary.debt|intcomma }}₽ + style="font-size: 16px; font-weight: bold;">{{ debts.buyers.summary.debt|intcomma }} ₽

Аванс: {{ debts.buyers.summary.advance|intcomma }}₽ + style="font-size: 16px; font-weight: bold;">{{ debts.buyers.summary.advance|intcomma }} ₽
-

Все задолженности

+

Все задолженности по покупателям

+
+
+ +
+ + +
+ Долг +
+
+ + Аванс +
+
+
+
{% for debtor in debts.buyers.main_group %} @@ -154,12 +193,11 @@ {{ debtor.counter_party }}
- Долг: - Аванс: + {{ debtor.debt|intcomma }} ₽
- {{ debtor.debt|intcomma }}₽ - {{ debtor.advance|intcomma }}₽ + + {{ debtor.advance|intcomma }} ₽
@@ -175,12 +213,10 @@ {{ debtor.counter_party }}
- Долг: - Аванс: + {{ debtor.debt|intcomma }} ₽
- {{ debtor.debt|intcomma }}₽ - {{ debtor.advance|intcomma }}₽ + {{ debtor.advance|intcomma }} ₽
@@ -195,22 +231,38 @@
-

Более 1% от общего долга

+

Более 1% от общего долга

Общая дебиторская задолженность по поставщикам
Долг: {{ debts.providers.summary.debt|intcomma }}₽ + style="font-size: 16px; font-weight: bold;">{{ debts.providers.summary.debt|intcomma }} ₽

Аванс: {{ debts.providers.summary.advance|intcomma }}₽ + style="font-size: 16px; font-weight: bold;">{{ debts.providers.summary.advance|intcomma }} ₽
-

Все задолженности

+

Все задолженности по поставщикам

+
+
+ +
+ + +
+ Долг +
+
+ Аванс +
+
+
+
{% for debtor in debts.providers.main_group %} @@ -223,12 +275,10 @@ {{ debtor.counter_party }}
- Долг: - Аванс: + {{ debtor.debt|intcomma }} ₽
- {{ debtor.debt|intcomma }}₽ - {{ debtor.advance|intcomma }}₽ + {{ debtor.advance|intcomma }} ₽
@@ -244,12 +294,10 @@ {{ debtor.counter_party }}
- Долг: - Аванс: + {{ debtor.debt|intcomma }} ₽
- {{ debtor.debt|intcomma }}₽ - {{ debtor.advance|intcomma }}₽ + {{ debtor.advance|intcomma }} ₽
@@ -306,6 +354,9 @@ } } }, + dataLabels: { + enabled: false + }, legend: { show: false } diff --git a/app/apps/util/base_view.py b/app/apps/util/base_view.py index 0a71c84..e164b7d 100644 --- a/app/apps/util/base_view.py +++ b/app/apps/util/base_view.py @@ -4,7 +4,8 @@ from datetime import datetime from django.conf import settings from django.db.models import QuerySet -from django.http import Http404, JsonResponse +from django.http import JsonResponse +from django.shortcuts import redirect from sabron.util import logging @@ -49,7 +50,7 @@ def group_required(*groups): def wrapper(request, *args, **kwargs): if request.user.groups.filter(name__in=groups).exists(): return function(request, *args, **kwargs) - raise Http404 + return redirect('main_index') return wrapper