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