Compare commits

...

5 Commits

8 changed files with 29 additions and 27 deletions

View File

@ -710,3 +710,13 @@ def invoice_item_formset_table(context, itemtxs_formset):
"total_amount__sum": context["total_amount__sum"], "total_amount__sum": context["total_amount__sum"],
"itemtxs_formset": itemtxs_formset, "itemtxs_formset": itemtxs_formset,
} }
@register.filter
def filter_by_status(queryset, status):
if status == "active":
return queryset.filter(active=True)
elif status == "locked":
return queryset.filter(locked=True)
else:
return queryset

View File

@ -4366,6 +4366,7 @@ class AccountListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["url_kwargs"] = self.kwargs context["url_kwargs"] = self.kwargs
context["coa_pk"] = self.kwargs["coa_pk"]
return context return context
@ -4412,17 +4413,7 @@ class AccountCreateView(
def form_valid(self, form): def form_valid(self, form):
dealer = get_user_type(self.request) dealer = get_user_type(self.request)
instance = form.save(commit=False)
coa = ChartOfAccountModel.objects.get(entity=dealer.entity,pk=self.kwargs["coa_pk"]) or self.request.entity.get_default_coa() coa = ChartOfAccountModel.objects.get(entity=dealer.entity,pk=self.kwargs["coa_pk"]) or self.request.entity.get_default_coa()
# coa.insert_account(account_model=instance)
account = coa.entity.create_account(
coa_model=coa,
code=instance.code,
name=instance.name,
role=instance.role,
balance_type=_(instance.balance_type),
active=True,
)
form.instance.entity_model = dealer.entity form.instance.entity_model = dealer.entity
form.instance.coa_model = coa form.instance.coa_model = coa
form.instance.depth = 0 form.instance.depth = 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 KiB

View File

@ -46,7 +46,7 @@
</section> </section>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl"> <div class="modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{% trans "Our Refund Policy" %}</h5> <h5 class="modal-title" id="exampleModalLabel">{% trans "Our Refund Policy" %}</h5>

View File

@ -1,4 +1,5 @@
{% load django_ledger %} {% load django_ledger %}
{% load custom_filters %}
{% load i18n %} {% load i18n %}
{% now "Y" as current_year %} {% now "Y" as current_year %}
<div class="card shadow-sm border-0 mb-4"> <div class="card shadow-sm border-0 mb-4">
@ -8,7 +9,7 @@
</div> </div>
<div class="flex-grow-1"> <div class="flex-grow-1">
<h5 class="fw-bold mb-0"> <h5 class="fw-bold mb-0">
{{ coa_model.name }}
{% if coa_model.is_default %} {% if coa_model.is_default %}
<span class="badge bg-light text-primary ms-2 d-none d-sm-inline">{% trans 'DEFAULT' %}</span> <span class="badge bg-light text-primary ms-2 d-none d-sm-inline">{% trans 'DEFAULT' %}</span>
{% endif %} {% endif %}
@ -47,15 +48,15 @@
<div class="col-sm-6"> <div class="col-sm-6">
<div class="mb-2"> <div class="mb-2">
<span class="fw-bold"><i class="fas fa-list-alt me-1"></i> {% trans 'Total Accounts' %}:</span> <span class="fw-bold"><i class="fas fa-list-alt me-1"></i> {% trans 'Total Accounts' %}:</span>
<span class="ms-2">{{ coa_model.accountmodel_total__count }}</span> <span class="ms-2">{{ coa_model.accountmodel_set.all|length }}</span>
</div> </div>
<div class="mb-2"> <div class="mb-2">
<span class="fw-bold text-info"><i class="fas fa-check-circle me-1"></i> {% trans 'Active Accounts' %}:</span> <span class="fw-bold text-info"><i class="fas fa-check-circle me-1"></i> {% trans 'Active Accounts' %}:</span>
<span class="ms-2">{{ coa_model.accountmodel_active__count }}</span> <span class="ms-2">{{ coa_model.accountmodel_set|filter_by_status:'active'|length }}</span>
</div> </div>
<div class="mb-2"> <div class="mb-2">
<span class="fw-bold text-danger"><i class="fas fa-lock me-1"></i> {% trans 'Locked Accounts' %}:</span> <span class="fw-bold text-danger"><i class="fas fa-lock me-1"></i> {% trans 'Locked Accounts' %}:</span>
<span class="ms-2">{{ coa_model.accountmodel_locked__count }}</span> <span class="ms-2">{{ coa_model.accountmodel_set|filter_by_status:'locked'|length }}</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -200,7 +200,7 @@
</div> </div>
</div> </div>
{% else %} {% else %}
{% url "account_create" request.dealer.slug as create_account_url %} {% url 'account_create' request.dealer.slug coa_pk as create_account_url %}
{% include "empty-illustration-page.html" with value="account" url=create_account_url %} {% include "empty-illustration-page.html" with value="account" url=create_account_url %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}