Compare commits
No commits in common. "521d3b63fa3e67ee567830549ffd51c8e1bf83b6" and "8d29202d3a4e3883d433e3b5c10e2037759e143e" have entirely different histories.
521d3b63fa
...
8d29202d3a
@ -45,11 +45,6 @@ class Sale(models.Model):
|
|||||||
return f"{self.date} {self.customer}"
|
return f"{self.date} {self.customer}"
|
||||||
|
|
||||||
|
|
||||||
def get_total(self):
|
|
||||||
lines = self.saleline_set.all()
|
|
||||||
return sum([l.quantity * l.unit_price for l in lines])
|
|
||||||
|
|
||||||
|
|
||||||
class SaleLine(models.Model):
|
class SaleLine(models.Model):
|
||||||
|
|
||||||
sale = models.ForeignKey(Sale, on_delete=models.CASCADE)
|
sale = models.ForeignKey(Sale, on_delete=models.CASCADE)
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
<h1>Resumen de compra</h1>
|
|
||||||
<dl>
|
|
||||||
<dt>Date</dt> <dd>{{ purchase.date }}</dd>
|
|
||||||
<dt>ID</dt> <dd>{{ purchase.id }}</dd>
|
|
||||||
<dt>Customer</dt> <dd>{{ purchase.customer }}</dd>
|
|
||||||
<dt>Total</dt> <dd>{{ purchase.get_total }}</dd>
|
|
||||||
</dl>
|
|
@ -1,31 +0,0 @@
|
|||||||
from django.test import TestCase, Client
|
|
||||||
from ..models import Sale, Product, SaleLine
|
|
||||||
|
|
||||||
class TestSummaryViewPurchase(TestCase):
|
|
||||||
def setUp(self):
|
|
||||||
self.client = Client()
|
|
||||||
purchase = Sale()
|
|
||||||
purchase.customer = "Alejo Mono"
|
|
||||||
purchase.date = "2024-07-30"
|
|
||||||
purchase.clean()
|
|
||||||
purchase.save()
|
|
||||||
|
|
||||||
product = Product()
|
|
||||||
product.name = "cafe"
|
|
||||||
product.price = "72500"
|
|
||||||
product.save()
|
|
||||||
|
|
||||||
line = SaleLine()
|
|
||||||
line.sale = purchase
|
|
||||||
line.product = product
|
|
||||||
line.quantity = "2"
|
|
||||||
line.unit_price = "72500"
|
|
||||||
line.save()
|
|
||||||
self.purchase = purchase
|
|
||||||
|
|
||||||
def test_summary_has_customer(self):
|
|
||||||
response = self.client.get("/don_confiao/resumen_compra/" + str(self.purchase.id))
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
self.assertEqual(response.context["purchase"].customer, self.purchase.customer)
|
|
||||||
self.assertIn('Alejo Mono', response.content.decode('utf-8'))
|
|
||||||
|
|
@ -12,5 +12,4 @@ urlpatterns = [
|
|||||||
path("importar_productos", views.import_products, name="import_products"),
|
path("importar_productos", views.import_products, name="import_products"),
|
||||||
path("cuadrar_tarro", views.reconciliate_jar, name="reconciliate_jar"),
|
path("cuadrar_tarro", views.reconciliate_jar, name="reconciliate_jar"),
|
||||||
path("cuadres", views.reconciliate_jar, name="reconciliations"),
|
path("cuadres", views.reconciliate_jar, name="reconciliations"),
|
||||||
path("resumen_compra/<int:id>", views.purchase_summary, name="purchase_summary"),
|
|
||||||
]
|
]
|
||||||
|
@ -102,15 +102,6 @@ def reconciliate_jar(request):
|
|||||||
def reconciliations(request):
|
def reconciliations(request):
|
||||||
return HttpResponse('<h1>Reconciliaciones</h1>')
|
return HttpResponse('<h1>Reconciliaciones</h1>')
|
||||||
|
|
||||||
def purchase_summary(request, id):
|
|
||||||
purchase = Sale.objects.get(pk=id)
|
|
||||||
return render(
|
|
||||||
request,
|
|
||||||
"don_confiao/purchase_summary.html",
|
|
||||||
{
|
|
||||||
"purchase" : purchase
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def _categories_from_csv_string(categories_string, separator="&"):
|
def _categories_from_csv_string(categories_string, separator="&"):
|
||||||
categories = categories_string.split(separator)
|
categories = categories_string.split(separator)
|
||||||
|
Loading…
Reference in New Issue
Block a user