coa acccounts add fixes
This commit is contained in:
parent
094deebf58
commit
40abbdbdaf
@ -1129,7 +1129,6 @@ class ChartOfAccountModelCreateView(ChartOfAccountModelModelBaseViewMixIn, Creat
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ChartOfAccountModelUpdateView(ChartOfAccountModelModelBaseViewMixIn, UpdateView):
|
class ChartOfAccountModelUpdateView(ChartOfAccountModelModelBaseViewMixIn, UpdateView):
|
||||||
context_object_name = "coa_model"
|
context_object_name = "coa_model"
|
||||||
slug_url_kwarg = "coa_slug"
|
slug_url_kwarg = "coa_slug"
|
||||||
|
|||||||
@ -4360,7 +4360,8 @@ class AccountListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
|
|||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
query = self.request.GET.get("q")
|
query = self.request.GET.get("q")
|
||||||
dealer = get_user_type(self.request)
|
dealer = get_user_type(self.request)
|
||||||
accounts = dealer.entity.get_all_accounts()
|
coa = ChartOfAccountModel.objects.get(entity=dealer.entity,pk=self.kwargs["coa_pk"]) or self.request.entity.get_default_coa()
|
||||||
|
accounts = coa.get_coa_accounts()
|
||||||
return apply_search_filters(accounts, query)
|
return apply_search_filters(accounts, query)
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
@ -4410,9 +4411,20 @@ class AccountCreateView(
|
|||||||
permission_required = ["django_ledger.add_accountmodel"]
|
permission_required = ["django_ledger.add_accountmodel"]
|
||||||
|
|
||||||
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.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 = dealer.entity.get_default_coa()
|
form.instance.coa_model = coa
|
||||||
form.instance.depth = 0
|
form.instance.depth = 0
|
||||||
form.instance.path = form.instance.code
|
form.instance.path = form.instance.code
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
@ -4420,13 +4432,15 @@ class AccountCreateView(
|
|||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
dealer = get_user_type(self.request)
|
dealer = get_user_type(self.request)
|
||||||
kwargs = super().get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
kwargs["coa_model"] = dealer.entity.get_default_coa()
|
coa = ChartOfAccountModel.objects.get(entity=dealer.entity,pk=self.kwargs["coa_pk"]) or self.request.entity.get_default_coa()
|
||||||
|
kwargs["coa_model"] = coa
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def get_form(self, form_class=None):
|
def get_form(self, form_class=None):
|
||||||
form = super().get_form(form_class)
|
form = super().get_form(form_class)
|
||||||
entity = get_user_type(self.request).entity
|
entity = get_user_type(self.request).entity
|
||||||
form.initial["coa_model"] = entity.get_default_coa()
|
coa = ChartOfAccountModel.objects.get(entity=entity,pk=self.kwargs["coa_pk"]) or self.request.entity.get_default_coa()
|
||||||
|
form.initial["coa_model"] = coa
|
||||||
return form
|
return form
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
@ -4436,12 +4450,13 @@ class AccountCreateView(
|
|||||||
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
|
||||||
coa_pk = context["url_kwargs"]["coa_pk"]
|
coa_pk = context["url_kwargs"]["coa_pk"]
|
||||||
try:
|
try:
|
||||||
kwargs["coa_model"] = ChartOfAccountModel.objects.get(pk=coa_pk) or self.request.entity.get_default_coa()
|
context["coa_model"] = ChartOfAccountModel.objects.get(entity=self.request.entity,pk=coa_pk)
|
||||||
except Exception:
|
except Exception:
|
||||||
kwargs["coa_model"] = self.request.entity.get_default_coa()
|
context["coa_model"] = self.request.entity.get_default_coa()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
class AccountDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
|
class AccountDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
Represents the detailed view for an account with additional context data related to account
|
Represents the detailed view for an account with additional context data related to account
|
||||||
@ -4540,7 +4555,11 @@ class AccountUpdateView(
|
|||||||
form.fields["_ref_node_id"].widget = HiddenInput()
|
form.fields["_ref_node_id"].widget = HiddenInput()
|
||||||
form.fields["_position"].widget = HiddenInput()
|
form.fields["_position"].widget = HiddenInput()
|
||||||
return form
|
return form
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
form.instance.coa_model = ChartOfAccountModel.objects.get(pk=self.kwargs['coa_pk']) or self.request.entity.get_default_coa()
|
||||||
|
return super().form_valid(form)
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy(
|
return reverse_lazy(
|
||||||
"account_list", kwargs={"dealer_slug": self.kwargs["dealer_slug"],"coa_pk":self.kwargs["coa_pk"]}
|
"account_list", kwargs={"dealer_slug": self.kwargs["dealer_slug"],"coa_pk":self.kwargs["coa_pk"]}
|
||||||
@ -4551,9 +4570,9 @@ class AccountUpdateView(
|
|||||||
context["url_kwargs"] = self.kwargs
|
context["url_kwargs"] = self.kwargs
|
||||||
coa_pk = context["url_kwargs"]["coa_pk"]
|
coa_pk = context["url_kwargs"]["coa_pk"]
|
||||||
try:
|
try:
|
||||||
kwargs["coa_model"] = ChartOfAccountModel.objects.get(pk=coa_pk) or self.request.entity.get_default_coa()
|
context["coa_model"] = ChartOfAccountModel.objects.get(pk=coa_pk) or self.request.entity.get_default_coa()
|
||||||
except Exception:
|
except Exception:
|
||||||
kwargs["coa_model"] = self.request.entity.get_default_coa()
|
context["coa_model"] = self.request.entity.get_default_coa()
|
||||||
return context
|
return context
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required("django_ledger.delete_accountmodel")
|
@permission_required("django_ledger.delete_accountmodel")
|
||||||
@ -11421,7 +11440,10 @@ def staff_password_reset_view(request, dealer_slug, user_pk):
|
|||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = forms.CustomSetPasswordForm(staff.user, request.POST)
|
form = forms.CustomSetPasswordForm(staff.user, request.POST)
|
||||||
|
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
|
print(form.cleaned_data['new_password1'])
|
||||||
|
print(form.cleaned_data['new_password2'])
|
||||||
form.save()
|
form.save()
|
||||||
messages.success(request, _('Your password has been set. You may go ahead and log in now.'))
|
messages.success(request, _('Your password has been set. You may go ahead and log in now.'))
|
||||||
return redirect('user_detail',dealer_slug=dealer_slug,slug=staff.slug)
|
return redirect('user_detail',dealer_slug=dealer_slug,slug=staff.slug)
|
||||||
@ -11662,12 +11684,12 @@ def ticket_update(request, ticket_id):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class ChartOfAccountModelListView(ChartOfAccountModelListViewBase):
|
# class ChartOfAccountModelListView(ChartOfAccountModelListViewBase):
|
||||||
template_name = 'chart_of_accounts/coa_list.html'
|
# template_name = 'chart_of_accounts/coa_list.html'
|
||||||
permission_required = 'django_ledger.view_chartofaccountmodel'
|
# permission_required = 'django_ledger.view_chartofaccountmodel'
|
||||||
class ChartOfAccountModelCreateView(ChartOfAccountModelCreateViewBase):
|
class ChartOfAccountModelCreateView(ChartOfAccountModelCreateViewBase):
|
||||||
template_name = 'chart_of_accounts/coa_create.html'
|
template_name = 'chart_of_accounts/coa_create.html'
|
||||||
permission_required = 'django_ledger.add_chartofaccountmodel'
|
permission_required = 'django_ledger.add_chartofaccountmodel'
|
||||||
class ChartOfAccountModelListView(ChartOfAccountModelListViewBase):
|
class ChartOfAccountModelListView(ChartOfAccountModelListViewBase):
|
||||||
template_name = 'chart_of_accounts/coa_list.html'
|
template_name = 'chart_of_accounts/coa_list.html'
|
||||||
permission_required = 'django_ledger.view_chartofaccountmodel'
|
permission_required = 'django_ledger.view_chartofaccountmodel'
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
<div class="card-header bg-gradient py-4 border-0 rounded-top-4">
|
<div class="card-header bg-gradient py-4 border-0 rounded-top-4">
|
||||||
<h3 class="mb-0 fs-4 fw-bold text-center">
|
<h3 class="mb-0 fs-4 fw-bold text-center">
|
||||||
{% trans 'Create Chart of Accounts' %}
|
{% trans 'Create Chart of Accounts' %}
|
||||||
<i class="fa-solid fa-chart-pie ms-2"></i>
|
<i class="fa-solid fa-chart-pie ms-2"></i>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body p-4 p-md-5">
|
<div class="card-body p-4 p-md-5">
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% trans "Add New Account" %}
|
{% trans "Add New Account" %}
|
||||||
<i class="fa-solid fa-book ms-2"></i>
|
<i class="fa-solid fa-book ms-2"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body p-4 p-md-5">
|
<div class="card-body p-4 p-md-5">
|
||||||
|
|||||||
@ -1,79 +1,108 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block title %}
|
{% block title %}{% trans 'Order Details' %}{% endblock %}
|
||||||
{% trans 'Order Details' %}
|
|
||||||
{% endblock %}
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
$('a.invoice').click(function () {
|
$('a.invoice-link').on('click', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
window.open($(this).attr('href'), 'plans_invoice_{{ invoice.id }}', 'width=860,resizable=1,location=0,status=0,titlebar=1');
|
window.open($(this).attr('href'), 'invoice_' + $(this).data('invoice-id'), 'width=860,resizable=1,location=0,status=0,titlebar=1');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1 class="mt-4">
|
<div class="max-w-4xl mx-auto">
|
||||||
{% blocktrans with object.id as order_id and object.get_status_display as order_status %}Order #{{ order_id }}
|
<div class="flex items-center justify-between mb-6">
|
||||||
(status: {{ order_status }}){% endblocktrans %}
|
<h1 class="text-3xl font-bold text-gray-800">
|
||||||
</h1>
|
{% blocktrans with object.id as order_id %}Order #{{ order_id }}{% endblocktrans %}
|
||||||
{# You should provide displaying django messages in this template #}
|
</h1>
|
||||||
{% with object as order %}
|
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium
|
||||||
{% include "plans/order_detail_table.html" %}
|
{% if object.status == object.STATUS.COMPLETED %}bg-green-100 text-green-800{% elif object.status == object.STATUS.PENDING %}bg-yellow-100 text-yellow-800{% else %}bg-gray-100 text-gray-800{% endif %}">
|
||||||
{% endwith %}
|
<i class="fas {% if object.status == object.STATUS.COMPLETED %}fa-check-circle{% elif object.status == object.STATUS.PENDING %}fa-clock{% else %}fa-info-circle{% endif %} mr-2"></i>
|
||||||
|
{{ object.get_status_display }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# Order Summary Section #}
|
||||||
|
<div class="rounded-xl shadow-sm overflow-hidden mb-6">
|
||||||
|
<div class="px-6 py-4">
|
||||||
|
<h2 class="text-xl font-semibold text-gray-800 mb-4">{% trans "Order Summary" %}</h2>
|
||||||
|
{% with object as order %}
|
||||||
|
{% include "plans/order_detail_table.html" %}
|
||||||
|
{% endwith %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# Printable Documents Section #}
|
||||||
{% if object.get_all_invoices.count %}
|
{% if object.get_all_invoices.count %}
|
||||||
<h2 class="mt-4">{% trans "Printable documents" %}</h2>
|
<div class="rounded-xl shadow-sm overflow-hidden mb-6">
|
||||||
<ul id="order_printable_documents">
|
<div class="px-6 py-4">
|
||||||
{% for invoice in object.get_all_invoices %}
|
<h2 class="text-xl font-semibold text-gray-800 mb-4">
|
||||||
|
<i class="fas fa-file-pdf text-gray-400 mr-2"></i> {% trans "Printable documents" %}
|
||||||
|
</h2>
|
||||||
|
<ul class="space-y-2">
|
||||||
|
{% for invoice in object.get_all_invoices %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ invoice.get_absolute_url }}" class="invoice">{{ invoice.get_type_display }} {{ invoice }}</a>
|
<a href="{{ invoice.get_absolute_url }}" data-invoice-id="{{ invoice.id }}" class="invoice-link text-blue-600 hover:text-blue-800 font-medium transition-colors duration-200">
|
||||||
|
{{ invoice.get_type_display }} {{ invoice }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
</div>
|
||||||
<h2 class="mt-4">{% trans "Payment" %}</h2>
|
</div>
|
||||||
{% if object.completed %}
|
{% endif %}
|
||||||
<p class="alert alert-phoenix-success mt-2">
|
|
||||||
{% blocktrans with object.completed as completed %}
|
{# Payment Section #}
|
||||||
Payment completed on: {{ completed }}
|
<div class="rounded-xl overflow-hidden mb-6">
|
||||||
{% endblocktrans %}
|
<div class="px-6 py-4">
|
||||||
</p>
|
<h2 class="text-xl font-semibold text-gray-800 mb-4">
|
||||||
{% else %}
|
<i class="fas fa-credit-card text-gray-400 mr-2"></i> {% trans "Payment" %}
|
||||||
{% if object.is_ready_for_payment %}
|
</h2>
|
||||||
{% block payment_method %}
|
{% if object.completed %}
|
||||||
<p class="mt-2">
|
<div class="bg-green-50 text-green-700 px-4 py-3 rounded-lg flex items-center">
|
||||||
Here should go bindings to your payment. We recommend using <a href="https://github.com/cypreess/django-getpaid">django-getpaid</a> for payment processing.
|
<i class="fas fa-check-circle mr-3 text-lg"></i>
|
||||||
Use a fake payment below to simulate paying for an order:
|
<p class="text-sm font-medium">
|
||||||
|
{% blocktrans with object.completed as completed %}
|
||||||
|
Payment completed on: {{ completed|date:"F j, Y" }}
|
||||||
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
<a class="btn btn-phoenix-success"
|
</div>
|
||||||
role="button"
|
|
||||||
href="{% url "fake_payments" pk=object.id %}">Pay using
|
|
||||||
FakePayments™ ;</a>
|
|
||||||
{# An example code snippet for accepting payments using django-getpaid #}
|
|
||||||
{# <form action="{% url "getpaid-new-payment" currency=object.currency %}" method="post"#}
|
|
||||||
{# class="standard_form payment_form">#}
|
|
||||||
{# {% csrf_token %}#}
|
|
||||||
{# <ul>{{ payment_form.as_ul }}</ul>#}
|
|
||||||
{# <p><label> </label><input type="submit"
|
|
||||||
value="{% trans "Pay the order" %}"
|
|
||||||
class="submit_button">#}
|
|
||||||
{# </p>#}
|
|
||||||
{# </form>#}
|
|
||||||
{% endblock %}
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="alert alert-phoenix-warning mt-2">
|
{% if object.is_ready_for_payment %}
|
||||||
{% blocktrans %}
|
<p class="text-gray-600 mb-4">
|
||||||
This order is expired. It will accept an incoming payment made earlier, but new payment cannot be
|
You can use a fake payment below to simulate paying for this order.
|
||||||
initialized. Please make a new order if necessary.
|
</p>
|
||||||
{% endblocktrans %}
|
<a class="inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-lg shadow-sm text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 transition-colors duration-200"
|
||||||
</p>
|
role="button"
|
||||||
|
href="{% url "fake_payments" pk=object.id %}">
|
||||||
|
<i class="fas fa-money-bill-wave mr-2"></i>
|
||||||
|
Pay using FakePayments™
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<div class="bg-yellow-50 text-yellow-700 px-4 py-3 rounded-lg flex items-center">
|
||||||
|
<i class="fas fa-exclamation-triangle mr-3 text-lg"></i>
|
||||||
|
<p class="text-sm font-medium">
|
||||||
|
{% blocktrans %}
|
||||||
|
This order is expired. New payments cannot be initialized. Please make a new order if necessary.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
{% if object.status == object.STATUS.NOT_VALID %}
|
{% if object.status == object.STATUS.NOT_VALID %}
|
||||||
<p class="alert alert-phoenix-danger">
|
<div class="bg-red-50 text-red-700 px-4 py-3 rounded-lg mt-4 flex items-center">
|
||||||
{% blocktrans %}
|
<i class="fas fa-times-circle mr-3 text-lg"></i>
|
||||||
This order could not be processed as it is not valid. Please contact with customer service.
|
<p class="text-sm font-medium">
|
||||||
{% endblocktrans %}
|
{% blocktrans %}
|
||||||
</p>
|
This order could not be processed as it is not valid. Please contact customer service.
|
||||||
{% endif %}
|
{% endblocktrans %}
|
||||||
{% endblock %}
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Loading…
x
Reference in New Issue
Block a user