mirror of
https://github.com/ae-utbm/sith.git
synced 2026-06-04 23:29:24 +00:00
Merge pull request #1410 from ae-utbm/fix-payment-method
fix: wrong payment method for refills with eboutic
This commit is contained in:
+6
-7
@@ -219,16 +219,14 @@ class Invoice(models.Model):
|
||||
if self.validated:
|
||||
raise DataError(_("Invoice already validated"))
|
||||
customer, _created = Customer.get_or_create(user=self.user)
|
||||
kwargs = {
|
||||
"counter": get_eboutic(),
|
||||
"customer": customer,
|
||||
"date": self.date,
|
||||
"payment_method": Selling.PaymentMethod.CARD,
|
||||
}
|
||||
kwargs = {"counter": get_eboutic(), "customer": customer, "date": self.date}
|
||||
for i in self.items.select_related("product"):
|
||||
if i.product.product_type_id == settings.SITH_COUNTER_PRODUCTTYPE_REFILLING:
|
||||
Refilling.objects.create(
|
||||
**kwargs, operator=self.user, amount=i.unit_price * i.quantity
|
||||
**kwargs,
|
||||
operator=self.user,
|
||||
amount=i.unit_price * i.quantity,
|
||||
payment_method=Refilling.PaymentMethod.CARD,
|
||||
)
|
||||
else:
|
||||
Selling.objects.create(
|
||||
@@ -239,6 +237,7 @@ class Invoice(models.Model):
|
||||
seller=self.user,
|
||||
unit_price=i.unit_price,
|
||||
quantity=i.quantity,
|
||||
payment_method=Selling.PaymentMethod.CARD,
|
||||
)
|
||||
self.validated = True
|
||||
self.save()
|
||||
|
||||
@@ -17,7 +17,7 @@ from pytest_django.asserts import assertRedirects
|
||||
|
||||
from core.baker_recipes import old_subscriber_user, subscriber_user
|
||||
from counter.baker_recipes import price_recipe, product_recipe
|
||||
from counter.models import Product, ProductType, Selling
|
||||
from counter.models import Product, ProductType, Refilling, Selling
|
||||
from counter.tests.test_counter import force_refill_user
|
||||
from eboutic.models import Basket, BasketItem
|
||||
|
||||
@@ -236,6 +236,10 @@ class TestPaymentCard(TestPaymentBase):
|
||||
|
||||
self.customer.customer.refresh_from_db()
|
||||
assert self.customer.customer.amount == price.amount * 2
|
||||
refill = self.customer.customer.refillings.last()
|
||||
assert refill is not None
|
||||
assert refill.amount == price.amount * 2
|
||||
assert refill.payment_method == Refilling.PaymentMethod.CARD
|
||||
|
||||
def test_multiple_responses(self):
|
||||
bank_response = self.generate_bank_valid_answer(self.basket)
|
||||
|
||||
Reference in New Issue
Block a user