update
This commit is contained in:
parent
a03bb8ccf1
commit
0cb378d25f
@ -342,7 +342,7 @@ class CarFinance(models.Model):
|
|||||||
total = 0
|
total = 0
|
||||||
if self.additional_services.count() != 0:
|
if self.additional_services.count() != 0:
|
||||||
total_additional_services = sum(x.default_amount for x in self.additional_services.all())
|
total_additional_services = sum(x.default_amount for x in self.additional_services.all())
|
||||||
total = self.selling_price + total_additional_services
|
total = self.selling_price + total_additional_services
|
||||||
else:
|
else:
|
||||||
total = self.selling_price
|
total = self.selling_price
|
||||||
if self.discount_amount != 0:
|
if self.discount_amount != 0:
|
||||||
|
|||||||
@ -1707,9 +1707,9 @@ def create_estimate(request):
|
|||||||
"item_number": item_instance.item_number,
|
"item_number": item_instance.item_number,
|
||||||
"quantity": float(item.get("quantity")),
|
"quantity": float(item.get("quantity")),
|
||||||
"unit_cost": car_instance.finances.cost_price,
|
"unit_cost": car_instance.finances.cost_price,
|
||||||
"unit_revenue": car_instance.finances.selling_price,
|
"unit_revenue": car_instance.finances.total_vat,
|
||||||
"total_amount": car_instance.finances.cost_price
|
"total_amount": car_instance.finances.total_vat
|
||||||
* int(item.get("quantity")),
|
* int(item.get("quantity")),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1786,24 +1786,21 @@ class EstimateDetailView(LoginRequiredMixin, DetailView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
estimate = kwargs.get("object")
|
estimate = kwargs.get("object")
|
||||||
if estimate.get_itemtxs_data():
|
if estimate.get_itemtxs_data():
|
||||||
total = sum(
|
total = sum(
|
||||||
(
|
(
|
||||||
x.ce_revenue_estimate
|
models.Car.objects.get(vin=x.item_model.name).finances.total_vat
|
||||||
- models.Car.objects.get(
|
|
||||||
vin=x.item_model.name
|
|
||||||
).finances.discount_amount
|
|
||||||
)
|
)
|
||||||
for x in estimate.get_itemtxs_data()[0].all()
|
for x in estimate.get_itemtxs_data()[0].all()
|
||||||
)
|
)
|
||||||
vat = models.VatRate.objects.filter(is_active=True).first()
|
vat = models.VatRate.objects.filter(is_active=True).first()
|
||||||
|
|
||||||
vat_amount = round(total * vat.vat_rate, 2)
|
vat_amount = round(total * vat.vat_rate, 2)
|
||||||
grand_total = round(
|
# grand_total = round(
|
||||||
(total * vat.vat_rate) + total, 2
|
# (total * vat.vat_rate) + total, 2
|
||||||
)
|
# )
|
||||||
kwargs["vat_amount"] = vat_amount
|
kwargs["vat_amount"] = vat_amount
|
||||||
kwargs["total"] = grand_total
|
kwargs["total"] = total
|
||||||
kwargs["vat"] = vat.rate
|
kwargs["vat"] = vat.rate
|
||||||
kwargs["invoice"] = (
|
kwargs["invoice"] = (
|
||||||
InvoiceModel.objects.all().filter(ce_model=estimate).first()
|
InvoiceModel.objects.all().filter(ce_model=estimate).first()
|
||||||
@ -1964,11 +1961,15 @@ def invoice_create(request, pk):
|
|||||||
invoice_model.save()
|
invoice_model.save()
|
||||||
|
|
||||||
unit_items = estimate.get_itemtxs_data()[0]
|
unit_items = estimate.get_itemtxs_data()[0]
|
||||||
|
|
||||||
|
# for item in unit_items:
|
||||||
|
# car = models.Car.objects.get(vin=item.item_model.name)
|
||||||
|
|
||||||
invoice_itemtxs = {
|
invoice_itemtxs = {
|
||||||
i.item_model.item_number: {
|
i.item_model.item_number: {
|
||||||
"unit_cost": i.ce_unit_cost_estimate,
|
"unit_cost": i.ce_unit_revenue_estimate,
|
||||||
"quantity": i.ce_quantity,
|
"quantity": i.ce_quantity,
|
||||||
"total_amount": i.ce_cost_estimate,
|
"total_amount": i.ce_revenue_estimate,
|
||||||
}
|
}
|
||||||
for i in unit_items
|
for i in unit_items
|
||||||
}
|
}
|
||||||
@ -2308,7 +2309,7 @@ def send_email_view(request, pk):
|
|||||||
request.POST.get("subject"),
|
request.POST.get("subject"),
|
||||||
request.POST.get("message"),
|
request.POST.get("message"),
|
||||||
)
|
)
|
||||||
# estimate.mark_as_review()
|
estimate.mark_as_review()
|
||||||
messages.success(request, "Email sent successfully!")
|
messages.success(request, "Email sent successfully!")
|
||||||
return redirect("estimate_detail", pk=estimate.pk)
|
return redirect("estimate_detail", pk=estimate.pk)
|
||||||
link = reverse_lazy("estimate_preview", kwargs={"pk": estimate.pk})
|
link = reverse_lazy("estimate_preview", kwargs={"pk": estimate.pk})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user