Feat: SaleLine
This commit is contained in:
parent
03b2395074
commit
bc7e96d64c
19
tienda_ilusion/don_confiao/migrations/0003_saleline.py
Normal file
19
tienda_ilusion/don_confiao/migrations/0003_saleline.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.0.6 on 2024-06-22 15:50
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('don_confiao', '0002_sale_customer_sale_date_sale_description_sale_phone'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SaleLine',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
],
|
||||
),
|
||||
]
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.6 on 2024-06-22 16:00
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('don_confiao', '0003_saleline'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='saleline',
|
||||
name='quantity',
|
||||
field=models.IntegerField(null=True),
|
||||
),
|
||||
]
|
20
tienda_ilusion/don_confiao/migrations/0005_saleline_sale.py
Normal file
20
tienda_ilusion/don_confiao/migrations/0005_saleline_sale.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Generated by Django 5.0.6 on 2024-06-22 16:05
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('don_confiao', '0004_saleline_quantity'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='saleline',
|
||||
name='sale',
|
||||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='don_confiao.sale'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
@ -7,3 +7,9 @@ class Sale(models.Model):
|
||||
date = models.DateField("Date")
|
||||
phone = models.CharField(max_length=13)
|
||||
description = models.CharField(max_length=255)
|
||||
|
||||
|
||||
class SaleLine(models.Model):
|
||||
|
||||
sale = models.ForeignKey(Sale, on_delete=models.CASCADE)
|
||||
quantity = models.IntegerField(null=True)
|
||||
|
@ -1,5 +1,5 @@
|
||||
from django.test import TestCase
|
||||
from .models import Sale
|
||||
from .models import Sale, SaleLine
|
||||
|
||||
|
||||
class ConfiaoTest(TestCase):
|
||||
@ -16,3 +16,21 @@ class ConfiaoTest(TestCase):
|
||||
sale.save()
|
||||
|
||||
self.assertIsInstance(sale, Sale)
|
||||
|
||||
def test_create_sale_line(self):
|
||||
sale = Sale()
|
||||
sale.customer = "Alejandro"
|
||||
sale.date = "2024-06-22"
|
||||
sale.phone = '666666666'
|
||||
sale.description = "Description"
|
||||
|
||||
line = SaleLine()
|
||||
line.sale = sale
|
||||
line.product = 'papaya'
|
||||
line.quantity = 2
|
||||
line.unit_price = 2500
|
||||
line.amount = 5000
|
||||
sale.save()
|
||||
line.save()
|
||||
# raise Exception(SaleLine.objects.all())
|
||||
self.assertEqual(SaleLine.objects.all()[0].quantity, 2)
|
||||
|
Loading…
Reference in New Issue
Block a user