diff --git a/core/tests/test_user.py b/core/tests/test_user.py index 6d99d2a2..77ca0fe0 100644 --- a/core/tests/test_user.py +++ b/core/tests/test_user.py @@ -186,13 +186,7 @@ class TestFilterInactive(TestCase): time_active = now() - settings.SITH_ACCOUNT_INACTIVITY_DELTA + timedelta(days=1) time_inactive = time_active - timedelta(days=3) counter, seller = baker.make(Counter), baker.make(User) - sale_recipe = Recipe( - Selling, - counter=counter, - club=counter.club, - seller=seller, - is_validated=True, - ) + sale_recipe = Recipe(Selling, counter=counter, club=counter.club, seller=seller) cls.users = [ baker.make(User), diff --git a/counter/management/commands/dump_accounts.py b/counter/management/commands/dump_accounts.py index b25cb93c..de8d113a 100644 --- a/counter/management/commands/dump_accounts.py +++ b/counter/management/commands/dump_accounts.py @@ -119,7 +119,6 @@ class Command(BaseCommand): quantity=1, unit_price=account.amount, date=now(), - is_validated=True, ) for account in accounts ] diff --git a/counter/migrations/0035_remove_selling_is_validated_and_more.py b/counter/migrations/0035_remove_selling_is_validated_and_more.py new file mode 100644 index 00000000..37d4997b --- /dev/null +++ b/counter/migrations/0035_remove_selling_is_validated_and_more.py @@ -0,0 +1,12 @@ +# Generated by Django 5.2.8 on 2025-11-19 17:59 + +from django.db import migrations, models +from django.db.migrations.state import StateApps + + +class Migration(migrations.Migration): + dependencies = [("counter", "0034_alter_selling_date_selling_date_month_idx")] + + operations = [ + migrations.RemoveField(model_name="selling", name="is_validated"), + ] diff --git a/counter/models.py b/counter/models.py index f98f3e44..1e07be3b 100644 --- a/counter/models.py +++ b/counter/models.py @@ -856,7 +856,6 @@ class Selling(models.Model): choices=[("SITH_ACCOUNT", _("Sith account")), ("CARD", _("Credit card"))], default="SITH_ACCOUNT", ) - is_validated = models.BooleanField(_("is validated"), default=False) objects = SellingQuerySet.as_manager() @@ -875,10 +874,9 @@ class Selling(models.Model): if not self.date: self.date = timezone.now() self.full_clean() - if not self.is_validated: + if self._state.adding and self.payment_method == "SITH_ACCOUNT": self.customer.amount -= self.quantity * self.unit_price self.customer.save(allow_negative=allow_negative) - self.is_validated = True user = self.customer.user if user.was_subscribed: if ( diff --git a/counter/tests/test_account_dump.py b/counter/tests/test_account_dump.py index db074efb..0d41576e 100644 --- a/counter/tests/test_account_dump.py +++ b/counter/tests/test_account_dump.py @@ -116,7 +116,6 @@ class TestAccountDumpCommand(TestAccountDump): operation: Selling = customer.buyings.order_by("date").last() assert operation.unit_price == initial_amount assert operation.counter_id == settings.SITH_COUNTER_ACCOUNT_DUMP_ID - assert operation.is_validated is True dump = customer.dumps.last() assert dump.dump_operation == operation diff --git a/counter/views/invoice.py b/counter/views/invoice.py index 63585796..c42090d6 100644 --- a/counter/views/invoice.py +++ b/counter/views/invoice.py @@ -75,7 +75,6 @@ class InvoiceCallView( kwargs["sum_cb"] += ( Selling.objects.filter( payment_method="CARD", - is_validated=True, date__gte=start_date, date__lte=end_date, ) diff --git a/eboutic/models.py b/eboutic/models.py index f0016073..6d71e025 100644 --- a/eboutic/models.py +++ b/eboutic/models.py @@ -268,7 +268,6 @@ class Invoice(models.Model): unit_price=i.product_unit_price, quantity=i.quantity, payment_method="CARD", - is_validated=True, date=self.date, ) new.save() diff --git a/eboutic/tests/test_basket.py b/eboutic/tests/test_basket.py index ff7f2077..b4d0cedf 100644 --- a/eboutic/tests/test_basket.py +++ b/eboutic/tests/test_basket.py @@ -108,10 +108,13 @@ def test_eboutic_basket_expiry( client.force_login(customer.user) - for date in sellings: - sale_recipe.make( - customer=customer, counter=eboutic, date=date, is_validated=True - ) + sale_recipe.make( + customer=customer, + counter=eboutic, + date=iter(sellings), + _quantity=len(sellings), + _bulk_create=True, + ) for date in refillings: refill_recipe.make(customer=customer, counter=eboutic, date=date)