Merge pull request 'Changed the PO detail and the salesorder page' (#116) from frontend into main

Reviewed-on: #116
This commit is contained in:
ismail 2025-07-08 11:30:58 +03:00
commit c2642fea78
11 changed files with 115 additions and 75 deletions

View File

@ -2554,6 +2554,15 @@ class CustomGroup(models.Model):
pass
def set_default_permissions(self):
Permission.objects.get_or_create(name="Can approve estimate",codename="can_approve_estimatemodel",content_type=ContentType.objects.get_for_model(EstimateModel))
Permission.objects.get_or_create(name="Can approve bill",codename="can_approve_billmodel",content_type=ContentType.objects.get_for_model(BillModel))
Permission.objects.get_or_create(name="Can view inventory",codename="can_view_inventory",content_type=ContentType.objects.get_for_model(Car))
Permission.objects.get_or_create(name="Can view sales",codename="can_view_sales",content_type=ContentType.objects.get_for_model(EstimateModel))
Permission.objects.get_or_create(name="Can view crm",codename="can_view_crm",content_type=ContentType.objects.get_for_model(Lead))
Permission.objects.get_or_create(name="Can view financials",codename="can_view_financials",content_type=ContentType.objects.get_for_model(AccountModel))
Permission.objects.get_or_create(name="Can view reports",codename="can_view_reports",content_type=ContentType.objects.get_for_model(LedgerModel))
self.clear_permissions()
######################################
######################################
@ -2637,7 +2646,7 @@ class CustomGroup(models.Model):
allowed_models=[],
other_perms=[
"view_purchaseordermodel",
"can_view_financials",
]
)
######################################
@ -2658,6 +2667,7 @@ class CustomGroup(models.Model):
"staff",
"schedule",
"activity",
"lead",
"opportunity",
"customer",
"organization",
@ -2693,10 +2703,7 @@ class CustomGroup(models.Model):
"carfinance",
"notes",
"tasks",
"activity",
"vendor",
"poitemsuploaded"
],
"activity",],
other_perms=[
"view_car",
"view_carlocation",
@ -2704,6 +2711,7 @@ class CustomGroup(models.Model):
"view_carcolors",
"view_cartransfer",
"view_saleorder",
],
)
self.set_permissions(
@ -2715,6 +2723,7 @@ class CustomGroup(models.Model):
"itemmodel",
"invoicemodel",
"vendormodel",
"journalentrymodel",
"purchaseordermodel",
"estimatemodel",
@ -2972,22 +2981,4 @@ class ExtraInfo(models.Model):
verbose_name_plural = "Extra Info"
def __str__(self):
return f"ExtraInfo for {self.content_object} ({self.content_type})"
@classmethod
def get_sale_orders(cls, staff=None,is_dealer=False):
if not staff and not is_dealer:
return []
if is_dealer:
qs = ExtraInfo.objects.filter(
content_type=ContentType.objects.get_for_model(EstimateModel),
related_content_type=ContentType.objects.get_for_model(Staff),
)
else:
qs = ExtraInfo.objects.filter(
content_type=ContentType.objects.get_for_model(EstimateModel),
related_content_type=ContentType.objects.get_for_model(Staff),
related_object_id=staff.pk,
)
return [x.content_object.sale_orders.first for x in qs]
return f"ExtraInfo for {self.content_object} ({self.content_type})"

View File

@ -963,7 +963,11 @@ def create_po_fulfilled_notification(sender,instance,created,**kwargs):
@receiver(post_save, sender=models.Car)
def car_created_notification(sender, instance, created, **kwargs):
if created:
<<<<<<< HEAD
accountants = models.CustomGroup.objects.filter(dealer=instance.dealer,name__in=["Manager","Accountant","Inventory"]).first().group.user_set.all().distinct()
=======
accountants = models.CustomGroup.objects.filter(dealer=instance.dealer,name__in=["Manager","Accountant"]).first().group.user_set.all().distinct()
>>>>>>> b23e84331fbb3a8ce0814a04b68cd3380b93d3a2
for accountant in accountants:
models.Notification.objects.create(
user=accountant,
@ -972,6 +976,9 @@ def car_created_notification(sender, instance, created, **kwargs):
<a href="{instance.get_absolute_url()}" target="_blank">View</a>
""",
)
@receiver(post_save, sender=PurchaseOrderModel)
def po_fullfilled_notification(sender, instance, created, **kwargs):
if instance.is_fulfilled():

View File

@ -8678,9 +8678,8 @@ class LedgerModelCreateView(LedgerModelCreateViewBase):
)
def form_valid(self, form):
dealer = get_user_type(self.request)
instance = form.save(commit=False)
instance.entity = dealer.entity
dealer = get_user_type(self.request)
form.field["entity"] = dealer.entity
return super().form_valid(form)
def get_success_url(self):
@ -10052,7 +10051,6 @@ class BillModelActionForceMigrateView(BaseBillActionView):
@login_required
@permission_required("inventory.view_poitemsuploaded", raise_exception=True)
def view_items_inventory(request, dealer_slug, entity_slug, po_pk):
get_object_or_404(models.Dealer, slug=dealer_slug)
po = PurchaseOrderModel.objects.get(pk=po_pk)

View File

@ -184,10 +184,12 @@
</td>
<td class="align-items-start white-space-nowrap pe-2">
{% if bill_item.po_model_id %}
{% if perms.django_ledger.view_purchaseordermodel%}
<a class="btn btn-sm btn-phoenix-primary"
href="{% url 'purchase_order_detail' request.dealer.slug request.dealer.entity.slug bill_item.po_model_id %}">
{% trans 'View PO' %}
</a>
{% endif %}
{% endif %}
</td>
</tr>
@ -231,9 +233,11 @@
<h5 class="mb-0">{% trans 'Bill Notes' %}</h5>
</div>
</div>
{% if perms.django_ledger.change_billmodel%}
<div class="card-body">
{% include 'bill/includes/card_markdown.html' with style='card_1' title='' notes_html=bill.notes_html %}
</div>
{% endif %}
</div>
</div>
</div>

View File

@ -291,7 +291,7 @@
<div class="tab-pane fade" id="tab-notes" role="tabpanel" aria-labelledby="notes-tab">
<div class="mb-1 d-flex align-items-center justify-content-between">
<h3 class="mb-4" id="scrollspyNotes">{{ _("Notes") }}</h3>
{% if perms.inventory.change_lead%}
{% if perms.inventory.change_lead %}
<button class="btn btn-phoenix-primary btn-sm" type="button" onclick="reset_form()" data-bs-toggle="modal" data-bs-target="#noteModal"><span class="fas fa-plus me-1"></span>{{ _("Add Note") }}</button>
{% endif %}
</div>

View File

@ -52,16 +52,20 @@
</div>
</div>
<div class="card-footer d-flex ">
{% if perms.django_ledger.change_bankaccountmodel%}
<a class="btn btn-sm btn-phoenix-primary me-1" href="{% url 'bank_account_update' request.dealer.slug bank_account.pk %}">
<!--<i class="bi bi-pencil-square"></i> -->
{{ _("Edit") }}
</a>
{% endif %}
{% if perms.django_ledger.delete_bankaccountmodel%}
<a class="btn btn-sm btn-phoenix-danger me-1"
data-bs-toggle="modal"
data-bs-target="#deleteModal">
<!--<i class="bi bi-trash-fill"></i>-->
{{ _("Delete") }}
</a>
{% endif %}
<a class="btn btn-sm btn-phoenix-secondary"
href="{% url 'bank_account_list' request.dealer.slug %}">
<!--<i class="bi bi-arrow-left-square-fill"></i>-->

View File

@ -96,12 +96,14 @@
{% endif %}
</td>
<td class="align-middle white-space-nowrap text-start">
{% if perms.django_ledger.view_transactionmodel%}
<div class="btn-reveal-trigger position-static">
<button class="btn btn-sm dropdown-toggle dropdown-caret-none transition-none btn-reveal fs-10" type="button" data-bs-toggle="dropdown" data-boundary="window" aria-haspopup="true" aria-expanded="false" data-bs-reference="parent"><span class="fas fa-ellipsis-h fs-10"></span></button>
<div class="dropdown-menu dropdown-menu-end py-2">
<a class="dropdown-item text-success-dark" href="{% url 'payment_details' request.dealer.slug tx.journal_entry.pk %}">{% trans 'view Transactions'|capfirst %}</a>
</div>
</div>
{% endif %}
</td>
</tr>
{% endfor %}
@ -135,17 +137,21 @@
</div>
<div class="mt-3 d-flex">
{% if perms.django_ledger.change_chartofaccountmodel%}
<a class="btn btn-sm btn-phoenix-primary me-1" href="{% url 'account_update' request.dealer.slug account.pk %}">
<!-- <i class="bi bi-pencil-square"></i> -->
<i class="fa-solid fa-pen-to-square"></i> {{ _('Edit') }}
</a>
{% endif %}
{% if perms.django_ledger.delete_chartofaccountmodel%}
<a class="btn btn-sm btn-phoenix-danger me-1" data-bs-toggle="modal" data-bs-target="#deleteModal">
<!-- <i class="bi bi-trash-fill"></i> -->
<i class="fa-solid fa-trash"></i> {{ _('Delete') }}
</a>
{% endif%}
<a class="btn btn-sm btn-phoenix-secondary" href="{% url 'account_list' request.dealer.slug %}">
<!-- <i class="bi bi-arrow-left-square-fill"></i> -->
<i class="fa-regular fa-circle-left"></i> {% trans 'Back to List' %}
<i class="fa-regular fa-circle-left"></i> {% trans 'Back to COA List' %}
</a>
</div>

View File

@ -11,7 +11,9 @@
<div class="row mt-4">
<div class="d-flex justify-content-between mb-2">
<h3 class=""><i class="fa-solid fa-book"></i> {% trans "Accounts" %}</h3>
{% if perms.django_ledger.create_chartofaccountmodel %}
<a href="{% url 'account_create' request.dealer.slug %}" class="btn btn-md btn-phoenix-primary"><i class="fa fa-plus me-2"></i>{% trans 'New Account' %}</a>
{% endif %}
</div>
<!-- Account Type Tabs -->
@ -105,10 +107,12 @@
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
{% if perms.django_ledger.delete_chartofaccountmodel %}
<h5 class="modal-title" id="deleteModalLabel">
{% trans "Delete Account" %}
<span data-feather="alert-circle"></span>
</h5>
{% endif %}
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body text-center">

View File

@ -10,7 +10,9 @@
<div class="d-flex justify-content-between mb-2">
<h3 class="">{% trans "Ledger" %}</h3>
{% if perms.django_ledger.add_ledgermodel %}
<a href="{% url 'ledger_create' request.dealer.slug request.dealer.entity.slug %}" class="btn btn-md btn-phoenix-primary"><i class="fa fa-plus me-2"></i>{% trans 'Create Ledger' %}</a>
{% endif %}
</div>
<div class="table-responsive px-1 scrollbar mt-3">
<table class="table align-items-center table-flush">
@ -32,14 +34,19 @@
<tr class="hover-actions-trigger btn-reveal-trigger position-static">
<td class="align-middle product white-space-nowrap px-1">
{% if ledger.invoicemodel %}
{% if perms.django_ledger.view_invoicemodel%}
<a href="{% url 'invoice_detail' request.dealer.slug ledger.invoicemodel.pk %}">{{ ledger.get_wrapped_model_instance }}</a>
{% endif %}
{% elif ledger.billmodel %}
{% if perms.django_ledger.view_billmodel %}
<a href="{% url 'bill-detail' request.dealer.slug request.dealer.entity.slug ledger.billmodel.pk %}">{{ ledger.get_wrapped_model_instance }}</a>
{% endif %}
{% else %}
<a href="#">{{ ledger.name }}</a>
{% endif %}
</td>
<td class="align-middle product white-space-nowrap">
{% if perms.django_ledger.view_journalentrymodel %}
<a class="btn btn-sm btn-phoenix-primary"
href="{% url 'journalentry_list' request.dealer.slug ledger.pk %}">
<i class="fa-solid fa-right-left"></i>
@ -48,6 +55,7 @@
<span>{{ _('Journal Entries') }}</span>
</span>
</a>
{% endif %}
</td>
<td class="align-middle product white-space-nowrap">
{{ ledger.created |date }}
@ -79,6 +87,7 @@
<span class="fas fa-ellipsis-h fs-10"></span>
</button>
<div class="dropdown-menu dropdown-menu-end py-2">
{% if perms.django_ledger.change_ledgermodel%}
{% if ledger.can_lock %}
<a href="{% url 'ledger-action-lock' dealer_slug=request.dealer.slug entity_slug=entity_slug ledger_pk=ledger.uuid %}"
class="dropdown-item has-text-info has-text-weight-bold">{% trans 'Lock' %}</a>
@ -109,6 +118,7 @@
<a href="{% url 'ledger-delete' dealer_slug=request.dealer.slug entity_slug=entity_slug ledger_pk=ledger.uuid %}"
class="dropdown-item has-text-danger has-text-weight-bold text-danger">{% trans 'Delete' %}</a>
{% endif %}
{% endif %}
</div>
</div>
</td>

View File

@ -8,45 +8,61 @@
<div class="container-fluid mt-4">
<div class="row g-1">
<div class="col-lg-12">
<div class="d-flex flex-column gap-3">
<div class="card">
<div class="card-body">
{% include 'purchase_orders/includes/card_po.html' with dealer_slug=request.dealer.slug po_model=po_model entity_slug=entity_slug style='po-detail' %}
</div>
<div class="col-lg-12 mb-3 ">
<div class="row">
<div class="col-9">
<div class="card">
<div class="card-body">
{% include 'purchase_orders/includes/card_po.html' with dealer_slug=request.dealer.slug po_model=po_model entity_slug=entity_slug style='po-detail' %}
</div>
</div>
</div>
<div class='col-3'>
<div class="row">
<div class="col-12">
<div class="card mb-4">
<div class="card-body">
<div class="row text-center">
<div class="col-md-6 border-end">
<div class="p-2">
<h6 class="text-muted mb-2">{% trans 'PO Amount' %}</h6>
<h3 class="fw-light mb-0">
<span class="currency">{{CURRENCY}}</span>{{ po_model.po_amount | absolute | currency_format }}
</h3>
</div>
</div>
<div class="col-md-6">
<div class="p-2">
<h6 class="text-muted mb-2">{% trans 'Amount Received' %}</h6>
<h3 class="fw-light mb-0 text-success">
<span class="currency">{{CURRENCY}}</span>{{ po_model.po_amount_received | currency_format }}
</h3>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-12">
<a class="btn btn-phoenix-primary w-100 py-2"
href="{% url 'purchase_order_list' request.dealer.slug request.dealer.entity.slug %}">
<i class="fas fa-list me-2"></i>{% trans 'PO List' %}
</a>
</div>
</div>
</div>
<a class="btn btn-phoenix-primary w-100 py-2"
href="{% url 'purchase_order_list' request.dealer.slug request.dealer.entity.slug %}">
<i class="fas fa-list me-2"></i>{% trans 'PO List' %}
</a>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="card mb-4">
<div class="card-body">
<div class="row text-center">
<div class="col-md-6 border-end">
<div class="p-2">
<h6 class="text-muted mb-2">{% trans 'PO Amount' %}</h6>
<h3 class="fw-light mb-0">
<span class="currency">{{CURRENCY}}</span>{{ po_model.po_amount | absolute | currency_format }}
</h3>
</div>
</div>
<div class="col-md-6">
<div class="p-2">
<h6 class="text-muted mb-2">{% trans 'Amount Received' %}</h6>
<h3 class="fw-light mb-0 text-success">
<span class="currency">{{CURRENCY}}</span>{{ po_model.po_amount_received | currency_format }}
</h3>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="table-responsive">

View File

@ -9,22 +9,22 @@
<style>
/* Custom styling */
.form-section {
background-color: #f8f9fa;
border-radius: 0.5rem;
padding: 1.5rem;
margin-bottom: 1.5rem;
}
.form-section-header {
border-bottom: 1px solid #dee2e6;
padding-bottom: 0.75rem;
margin-bottom: 1.5rem;
color: #0d6efd;
}
.required-field::after {
content: " *";
color: #dc3545;
}
.search-select {
@ -40,7 +40,7 @@
right: 1rem;
top: 50%;
transform: translateY(-50%);
color: #6c757d;
}
.currency-input {
@ -52,7 +52,7 @@
left: 1rem;
top: 50%;
transform: translateY(-50%);
color: #6c757d;
}
.currency-input input {
@ -60,12 +60,12 @@
}
.form-actions {
background-color: #f8f9fa;
padding: 1rem;
border-radius: 0.5rem;
position: sticky;
position:static;
bottom: 1rem;
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}
</style>
{% endblock customCSS %}
@ -75,7 +75,7 @@
<div class="row justify-content-center mb-4">
<div class="col-lg-10">
<div class="card shadow">
<div class="card-header bg-primary text-white">
<div class="card-header bg-primary ">
<div class="d-flex justify-content-between align-items-center">
<h2 class="h4 mb-0">
<i class="fas fa-file-invoice me-2"></i> New Sale Order