diff --git a/core/management/commands/populate_more.py b/core/management/commands/populate_more.py index 38803dc8..76115c70 100644 --- a/core/management/commands/populate_more.py +++ b/core/management/commands/populate_more.py @@ -350,7 +350,6 @@ class Command(BaseCommand): date=make_aware( self.faker.date_time_between(customer.since, localdate()) ), - is_validated=True, ) ) sales.extend(this_customer_sales) diff --git a/counter/migrations/0035_remove_selling_is_validated_and_more.py b/counter/migrations/0035_remove_selling_is_validated_and_more.py index b5ecf0b6..83da9643 100644 --- a/counter/migrations/0035_remove_selling_is_validated_and_more.py +++ b/counter/migrations/0035_remove_selling_is_validated_and_more.py @@ -19,6 +19,7 @@ class Migration(migrations.Migration): operations = [ migrations.RemoveField(model_name="selling", name="is_validated"), + migrations.RemoveField(model_name="refilling", name="is_validated"), migrations.RenameField( model_name="selling", old_name="payment_method", diff --git a/counter/models.py b/counter/models.py index 7324e0c2..f056102b 100644 --- a/counter/models.py +++ b/counter/models.py @@ -755,7 +755,6 @@ class Refilling(models.Model): bank = models.CharField( _("bank"), max_length=255, choices=settings.SITH_COUNTER_BANK, default="OTHER" ) - is_validated = models.BooleanField(_("is validated"), default=False) objects = RefillingQuerySet.as_manager() @@ -772,10 +771,9 @@ class Refilling(models.Model): if not self.date: self.date = timezone.now() self.full_clean() - if not self.is_validated: + if self._state.adding: self.customer.amount += self.amount self.customer.save() - self.is_validated = True if self.customer.user.preferences.notify_on_refill: Notification( user=self.customer.user, diff --git a/counter/tests/test_counter.py b/counter/tests/test_counter.py index af0e07ad..45b7bb13 100644 --- a/counter/tests/test_counter.py +++ b/counter/tests/test_counter.py @@ -53,7 +53,7 @@ def set_age(user: User, age: int): def force_refill_user(user: User, amount: Decimal | int): - baker.make(Refilling, amount=amount, customer=user.customer, is_validated=False) + baker.make(Refilling, amount=amount, customer=user.customer) class TestFullClickBase(TestCase): diff --git a/counter/views/invoice.py b/counter/views/invoice.py index 11702803..d990b609 100644 --- a/counter/views/invoice.py +++ b/counter/views/invoice.py @@ -67,10 +67,7 @@ class InvoiceCallView( end_date = start_date + relativedelta(months=1) kwargs["sum_cb"] = Refilling.objects.filter( - payment_method="CARD", - is_validated=True, - date__gte=start_date, - date__lte=end_date, + payment_method="CARD", date__gte=start_date, date__lte=end_date ).aggregate(res=Sum("amount", default=0))["res"] kwargs["sum_cb"] += ( Selling.objects.filter( diff --git a/eboutic/tests/test_basket.py b/eboutic/tests/test_basket.py index b4d0cedf..539502cc 100644 --- a/eboutic/tests/test_basket.py +++ b/eboutic/tests/test_basket.py @@ -108,15 +108,22 @@ def test_eboutic_basket_expiry( client.force_login(customer.user) - 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) + if sellings: + sale_recipe.make( + customer=customer, + counter=eboutic, + date=iter(sellings), + _quantity=len(sellings), + _bulk_create=True, + ) + if refillings: + refill_recipe.make( + customer=customer, + counter=eboutic, + date=iter(refillings), + _quantity=len(refillings), + _bulk_create=True, + ) assert ( f'x-data="basket({int(expected.timestamp() * 1000) if expected else "null"})"'