fix some stuff
This commit is contained in:
parent
b22ef36524
commit
a7d09e60e3
@ -971,7 +971,7 @@ def sale_order_created_notification(sender, instance, created, **kwargs):
|
|||||||
user=recipient,
|
user=recipient,
|
||||||
message=f"""
|
message=f"""
|
||||||
New Sale Order has been added for estimate:{instance.estimate}.
|
New Sale Order has been added for estimate:{instance.estimate}.
|
||||||
<a href="{reverse('estimate_detail',kwargs={'dealer_slug':instance.dealer.slug,'pk':instance.pk})}" target="_blank">View</a>
|
<a href="{reverse('estimate_detail',kwargs={'dealer_slug':instance.dealer.slug,'pk':instance.estimate.pk})}" target="_blank">View</a>
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
@receiver(post_save, sender=models.Lead)
|
@receiver(post_save, sender=models.Lead)
|
||||||
|
|||||||
@ -1005,6 +1005,7 @@ class CarFinanceCalculator:
|
|||||||
car_finance = self._get_nested_value(item, self.CAR_FINANCE_KEY)
|
car_finance = self._get_nested_value(item, self.CAR_FINANCE_KEY)
|
||||||
car_info = self._get_nested_value(item, self.CAR_INFO_KEY)
|
car_info = self._get_nested_value(item, self.CAR_INFO_KEY)
|
||||||
unit_price = Decimal(car_finance.get("selling_price", 0))
|
unit_price = Decimal(car_finance.get("selling_price", 0))
|
||||||
|
print(item.item_model.car.finances)
|
||||||
return {
|
return {
|
||||||
"item_number": item.item_model.item_number,
|
"item_number": item.item_model.item_number,
|
||||||
"vin": car_info.get("vin"),
|
"vin": car_info.get("vin"),
|
||||||
|
|||||||
@ -27,7 +27,7 @@ from django.views.decorators.http import require_http_methods
|
|||||||
from django.db.models.deletion import RestrictedError
|
from django.db.models.deletion import RestrictedError
|
||||||
from django.http.response import StreamingHttpResponse
|
from django.http.response import StreamingHttpResponse
|
||||||
from django.core.exceptions import ImproperlyConfigured, ValidationError
|
from django.core.exceptions import ImproperlyConfigured, ValidationError
|
||||||
|
from django.core.exceptions import PermissionDenied
|
||||||
# Django
|
# Django
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -3636,7 +3636,7 @@ class BankAccountListView(LoginRequiredMixin, PermissionRequiredMixin, ListView)
|
|||||||
template_name = "ledger/bank_accounts/bank_account_list.html"
|
template_name = "ledger/bank_accounts/bank_account_list.html"
|
||||||
context_object_name = "bank_accounts"
|
context_object_name = "bank_accounts"
|
||||||
paginate_by = 30
|
paginate_by = 30
|
||||||
permission_required = ["inventory.view_carfinance"]
|
permission_required = ["django_ledger.view_bankaccountmodel"]
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
query = self.request.GET.get("q")
|
query = self.request.GET.get("q")
|
||||||
@ -4275,7 +4275,12 @@ def create_estimate(request, dealer_slug, slug=None):
|
|||||||
# }
|
# }
|
||||||
# )
|
# )
|
||||||
car_instance = models.Car.objects.filter(
|
car_instance = models.Car.objects.filter(
|
||||||
hash=item.get("item_id"), finances__is_sold=False
|
hash=item.get("item_id"),
|
||||||
|
finances__is_sold=False,
|
||||||
|
colors__isnull=False,
|
||||||
|
finances__isnull=False,
|
||||||
|
finances__selling_price__gt=1,
|
||||||
|
status="available",
|
||||||
).all()
|
).all()
|
||||||
|
|
||||||
for i in car_instance[: int(quantities[0])]:
|
for i in car_instance[: int(quantities[0])]:
|
||||||
@ -4372,7 +4377,7 @@ def create_estimate(request, dealer_slug, slug=None):
|
|||||||
dealer=dealer,
|
dealer=dealer,
|
||||||
colors__isnull=False,
|
colors__isnull=False,
|
||||||
finances__isnull=False,
|
finances__isnull=False,
|
||||||
finances__selling_price__gt=0,
|
finances__selling_price__gt=1,
|
||||||
status="available",
|
status="available",
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
@ -4443,6 +4448,7 @@ class EstimateDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView
|
|||||||
if estimate.get_itemtxs_data():
|
if estimate.get_itemtxs_data():
|
||||||
calculator = CarFinanceCalculator(estimate)
|
calculator = CarFinanceCalculator(estimate)
|
||||||
finance_data = calculator.get_finance_data()
|
finance_data = calculator.get_finance_data()
|
||||||
|
print(finance_data)
|
||||||
invoice_obj = InvoiceModel.objects.all().filter(ce_model=estimate).first()
|
invoice_obj = InvoiceModel.objects.all().filter(ce_model=estimate).first()
|
||||||
kwargs["data"] = finance_data
|
kwargs["data"] = finance_data
|
||||||
kwargs["invoice"] = invoice_obj
|
kwargs["invoice"] = invoice_obj
|
||||||
@ -4643,7 +4649,6 @@ class EstimatePreviewView(LoginRequiredMixin, PermissionRequiredMixin, DetailVie
|
|||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required("django_ledger.change_estimatemodel", raise_exception=True)
|
|
||||||
def estimate_mark_as(request, dealer_slug, pk):
|
def estimate_mark_as(request, dealer_slug, pk):
|
||||||
"""
|
"""
|
||||||
Marks an estimate with a specified status based on the requested action and
|
Marks an estimate with a specified status based on the requested action and
|
||||||
@ -4660,6 +4665,11 @@ def estimate_mark_as(request, dealer_slug, pk):
|
|||||||
:return: A redirect response to the estimate detail view.
|
:return: A redirect response to the estimate detail view.
|
||||||
:rtype: HttpResponseRedirect
|
:rtype: HttpResponseRedirect
|
||||||
"""
|
"""
|
||||||
|
if not (
|
||||||
|
request.user.has_perm("django_ledger.can_approve_estimatemodel") or
|
||||||
|
request.user.has_perm("django_ledger.change_estimatemodel")
|
||||||
|
):
|
||||||
|
raise PermissionDenied
|
||||||
dealer = get_object_or_404(models.Dealer, slug=dealer_slug)
|
dealer = get_object_or_404(models.Dealer, slug=dealer_slug)
|
||||||
estimate = get_object_or_404(EstimateModel, pk=pk)
|
estimate = get_object_or_404(EstimateModel, pk=pk)
|
||||||
mark = request.GET.get("mark")
|
mark = request.GET.get("mark")
|
||||||
@ -4680,6 +4690,9 @@ def estimate_mark_as(request, dealer_slug, pk):
|
|||||||
)
|
)
|
||||||
estimate.mark_as_approved()
|
estimate.mark_as_approved()
|
||||||
messages.success(request, _("Quotation approved successfully"))
|
messages.success(request, _("Quotation approved successfully"))
|
||||||
|
return redirect(
|
||||||
|
"estimate_list", dealer_slug=dealer.slug
|
||||||
|
)
|
||||||
elif mark == "rejected":
|
elif mark == "rejected":
|
||||||
if not estimate.can_cancel():
|
if not estimate.can_cancel():
|
||||||
messages.error(request, _("Quotation is not ready for rejection"))
|
messages.error(request, _("Quotation is not ready for rejection"))
|
||||||
@ -5518,8 +5531,10 @@ def lead_create(request,dealer_slug):
|
|||||||
is_sa_import=True, pk__in=dealer_make_list
|
is_sa_import=True, pk__in=dealer_make_list
|
||||||
)
|
)
|
||||||
form.fields["staff"].queryset = form.fields["staff"].queryset.filter(
|
form.fields["staff"].queryset = form.fields["staff"].queryset.filter(
|
||||||
dealer=dealer
|
dealer=dealer,staff_member__user__groups__name__contains="Sales")
|
||||||
)
|
# form.fields["staff"].queryset = form.fields["staff"].queryset.filter(
|
||||||
|
# dealer=dealer
|
||||||
|
# )
|
||||||
|
|
||||||
if hasattr(request.user.staffmember, "staff"):
|
if hasattr(request.user.staffmember, "staff"):
|
||||||
form.initial["staff"] = request.user.staffmember.staff
|
form.initial["staff"] = request.user.staffmember.staff
|
||||||
|
|||||||
@ -76,14 +76,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-items-center gap-2">
|
<div class="d-flex align-items-center gap-2">
|
||||||
|
|
||||||
{% if estimate.status == 'draft' %}
|
{% if estimate.status == 'draft' %}
|
||||||
<a href="{% url 'send_email' request.dealer.slug estimate.pk %}" class="btn btn-phoenix-primary me-2"><span class="fa-regular fa-paper-plane me-sm-2"></span><span class="d-none d-sm-inline-block">{% trans 'Send Quotation' %}</span></a>
|
{% if perms.django_ledger.change_estimatemodel %}
|
||||||
<button id="mark_as_sent_estimate" class="btn btn-phoenix-secondary" onclick="setFormAction('review')" data-bs-toggle="modal" data-bs-target="#confirmModal"><span class="d-none d-sm-inline-block"><i class="fa-solid fa-check-double"></i> {% trans 'Mark As Sent' %}</span></button>
|
<button id="mark_as_sent_estimate" class="btn btn-phoenix-secondary" onclick="setFormAction('review')" data-bs-toggle="modal" data-bs-target="#confirmModal"><span class="d-none d-sm-inline-block"><i class="fa-solid fa-check-double"></i> {% trans 'Mark As Review' %}</span></button>
|
||||||
{% elif estimate.status == 'in_review' %}
|
{% endif %}
|
||||||
{% if perms.django_ledger.can_approve_estimatemodel %}
|
{% elif estimate.status == 'in_review' %}
|
||||||
<button id="accept_estimate" onclick="setFormAction('approved')" class="btn btn-phoenix-secondary" data-bs-toggle="modal" data-bs-target="#confirmModal"><span class="d-none d-sm-inline-block"><i class="fa-solid fa-check-double"></i> {% trans 'Mark As Accept' %}</span></button>
|
{% if perms.django_ledger.can_approve_estimatemodel %}
|
||||||
{% endif %}
|
<button id="accept_estimate" onclick="setFormAction('approved')" class="btn btn-phoenix-secondary" data-bs-toggle="modal" data-bs-target="#confirmModal"><span class="d-none d-sm-inline-block"><i class="fa-solid fa-check-double"></i> {% trans 'Mark As Accept' %}</span></button>
|
||||||
|
{% endif %}
|
||||||
{% elif estimate.status == 'approved' %}
|
{% elif estimate.status == 'approved' %}
|
||||||
|
<a href="{% url 'send_email' request.dealer.slug estimate.pk %}" class="btn btn-phoenix-primary me-2"><span class="fa-regular fa-paper-plane me-sm-2"></span><span class="d-none d-sm-inline-block">{% trans 'Send Quotation' %}</span></a>
|
||||||
|
|
||||||
{% if estimate.sale_orders.first %}
|
{% if estimate.sale_orders.first %}
|
||||||
<!--if sale order exist-->
|
<!--if sale order exist-->
|
||||||
@ -99,9 +101,9 @@
|
|||||||
|
|
||||||
|
|
||||||
{% elif estimate.status == 'completed' %}
|
{% elif estimate.status == 'completed' %}
|
||||||
<a href="{% url 'order_detail' request.dealer.slug estimate.sale_orders.first.pk %}" class="btn btn-phoenix-primary"><span class="d-none d-sm-inline-block">{{ _("Preview Sale Order") }}</span></a>
|
<a href="{% url 'order_detail' request.dealer.slug estimate.sale_orders.first.pk %}" class="btn btn-phoenix-primary"><span class="d-none d-sm-inline-block">{{ _("Preview Sale Order") }}</span></a>
|
||||||
<a href="{% url 'invoice_detail' request.dealer.slug estimate.invoicemodel_set.first.pk %}" class="btn btn-phoenix-primary btn-sm" type="button"><i class="fa-solid fa-receipt"></i>
|
<a href="{% url 'invoice_detail' request.dealer.slug estimate.invoicemodel_set.first.pk %}" class="btn btn-phoenix-primary btn-sm" type="button"><i class="fa-solid fa-receipt"></i>
|
||||||
{{ _("View Invoice")}}</a>
|
{{ _("View Invoice")}}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if estimate.can_cancel %}
|
{% if estimate.can_cancel %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user