fix the item services uom
This commit is contained in:
parent
9e373128a9
commit
bec001cbc0
@ -48,7 +48,7 @@ from imagekit.models import ImageSpecField
|
||||
from imagekit.processors import ResizeToFill
|
||||
# from plans.models import AbstractPlan
|
||||
# from simple_history.models import HistoricalRecords
|
||||
|
||||
from plans.models import Invoice
|
||||
|
||||
class Base(models.Model):
|
||||
id = models.UUIDField(
|
||||
@ -1262,6 +1262,9 @@ class Dealer(models.Model, LocalizedNameMixin):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@property
|
||||
def invoices(self):
|
||||
return Invoice.objects.filter(order__user=self.user)
|
||||
|
||||
class StaffTypes(models.TextChoices):
|
||||
# MANAGER = "manager", _("Manager")
|
||||
|
||||
@ -502,7 +502,7 @@ def create_item_service(sender, instance, created, **kwargs):
|
||||
"""
|
||||
if created:
|
||||
entity = instance.dealer.entity
|
||||
uom = entity.get_uom_all().get(name=str(instance.uom).lower())
|
||||
uom = entity.get_uom_all().filter(unit_abbr=instance.uom).first()
|
||||
cogs = (
|
||||
entity.get_all_accounts()
|
||||
.filter(role=roles.COGS, active=True, role_default=True)
|
||||
|
||||
@ -7203,6 +7203,7 @@ class ItemServiceCreateView(
|
||||
def form_valid(self, form):
|
||||
dealer = get_user_type(self.request)
|
||||
vat = models.VatRate.objects.get(dealer=dealer, is_active=True)
|
||||
|
||||
form.instance.dealer = dealer
|
||||
# if form.instance.taxable:
|
||||
# form.instance.price = (form.instance.price * vat.rate) + form.instance.price
|
||||
@ -7252,7 +7253,11 @@ class ItemServiceUpdateView(
|
||||
def form_valid(self, form):
|
||||
dealer = get_user_type(self.request)
|
||||
vat = models.VatRate.objects.get(dealer=dealer, is_active=True)
|
||||
uom = dealer.entity.get_uom_all().filter(unit_abbr=form.instance.uom).first()
|
||||
form.instance.dealer = dealer
|
||||
form.instance.uom = uom.name
|
||||
form.instance.item.uom = uom
|
||||
|
||||
# if form.instance.taxable:
|
||||
# form.instance.price = (form.instance.price * vat.rate) + form.instance.price
|
||||
return super().form_valid(form)
|
||||
|
||||
@ -84,7 +84,7 @@
|
||||
{% include "plans/expiration_messages.html" %}
|
||||
{% block period_navigation %}
|
||||
{% endblock period_navigation %}
|
||||
<div id="main_content" class="fade-me-in" hx-boost="true" hx-target="#main_content" hx-select="#main_content" hx-swap="innerHTML transition:true" hx-select-oob="#toast-container" hx-history-elt>
|
||||
<div id="main_content" class="fade-me-in" hx-boost="false" hx-target="#main_content" hx-select="#main_content" hx-swap="innerHTML transition:true" hx-select-oob="#toast-container" hx-history-elt>
|
||||
<div id="spinner" class="htmx-indicator spinner-bg">
|
||||
<img src="{% static 'spinner.svg' %}" width="100" height="100" alt="">
|
||||
</div>
|
||||
|
||||
@ -7,11 +7,12 @@
|
||||
<div class="row align-items-center justify-content-between g-3 mb-4">
|
||||
<div class="col-auto">
|
||||
<h2 class="mb-0">{% trans 'Profile' %}</h2>
|
||||
<small>{{dealer.invoices}}</small>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="row g-2 g-sm-3">
|
||||
<div class="col-auto">
|
||||
<a href="{% url 'order_list' %}" class="btn btn-phoenix-success"><span class="fas fa-list me-2"></span>{{ _("Orders") }}</a>
|
||||
<a hx-boost="false" href="{% url 'order_list' %}" class="btn btn-phoenix-success"><span class="fas fa-list me-2"></span>{{ _("Orders") }}</a>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="{% url 'billing_info' %}" class="btn btn-phoenix-info"><span class="fas fa-credit-card me-2"></span>{{ _("Billing Information") }}</a>
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
{% block title %}
|
||||
{% trans 'Cash Flow Statement' %} {% endblock %}
|
||||
{% block period_navigation %}
|
||||
{% if unit_model and entity %}
|
||||
<div class="col-12">{% period_navigation 'unit-cf' %}</div>
|
||||
{% if unit_model and entity %}
|
||||
<div class="col-12">{% period_navigation 'unit-cf' %}</div>
|
||||
{% elif entity %}
|
||||
<div class="col-12">{% period_navigation 'entity-cf' %}</div>
|
||||
<div class="col-12">{% period_navigation 'entity-cf' %}</div>
|
||||
{% elif ledger %}
|
||||
<div class="col-12">{% period_navigation 'ledger-cf' %}</div>
|
||||
<div class="col-12">{% period_navigation 'ledger-cf' %}</div>
|
||||
{% elif unit_model %}
|
||||
<div class="col-12">{% period_navigation 'unit-cf' %}</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
<div class="col-12">{% period_navigation 'unit-cf' %}</div>
|
||||
{% endif %}
|
||||
{% endblock period_navigation %}
|
||||
{% block content %}
|
||||
<div class="card">
|
||||
<div class="card-body text-center">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user