mirror of
https://github.com/ae-utbm/sith.git
synced 2026-06-05 07:39:21 +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:
|
if self.validated:
|
||||||
raise DataError(_("Invoice already validated"))
|
raise DataError(_("Invoice already validated"))
|
||||||
customer, _created = Customer.get_or_create(user=self.user)
|
customer, _created = Customer.get_or_create(user=self.user)
|
||||||
kwargs = {
|
kwargs = {"counter": get_eboutic(), "customer": customer, "date": self.date}
|
||||||
"counter": get_eboutic(),
|
|
||||||
"customer": customer,
|
|
||||||
"date": self.date,
|
|
||||||
"payment_method": Selling.PaymentMethod.CARD,
|
|
||||||
}
|
|
||||||
for i in self.items.select_related("product"):
|
for i in self.items.select_related("product"):
|
||||||
if i.product.product_type_id == settings.SITH_COUNTER_PRODUCTTYPE_REFILLING:
|
if i.product.product_type_id == settings.SITH_COUNTER_PRODUCTTYPE_REFILLING:
|
||||||
Refilling.objects.create(
|
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:
|
else:
|
||||||
Selling.objects.create(
|
Selling.objects.create(
|
||||||
@@ -239,6 +237,7 @@ class Invoice(models.Model):
|
|||||||
seller=self.user,
|
seller=self.user,
|
||||||
unit_price=i.unit_price,
|
unit_price=i.unit_price,
|
||||||
quantity=i.quantity,
|
quantity=i.quantity,
|
||||||
|
payment_method=Selling.PaymentMethod.CARD,
|
||||||
)
|
)
|
||||||
self.validated = True
|
self.validated = True
|
||||||
self.save()
|
self.save()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from pytest_django.asserts import assertRedirects
|
|||||||
|
|
||||||
from core.baker_recipes import old_subscriber_user, subscriber_user
|
from core.baker_recipes import old_subscriber_user, subscriber_user
|
||||||
from counter.baker_recipes import price_recipe, product_recipe
|
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 counter.tests.test_counter import force_refill_user
|
||||||
from eboutic.models import Basket, BasketItem
|
from eboutic.models import Basket, BasketItem
|
||||||
|
|
||||||
@@ -236,6 +236,10 @@ class TestPaymentCard(TestPaymentBase):
|
|||||||
|
|
||||||
self.customer.customer.refresh_from_db()
|
self.customer.customer.refresh_from_db()
|
||||||
assert self.customer.customer.amount == price.amount * 2
|
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):
|
def test_multiple_responses(self):
|
||||||
bank_response = self.generate_bank_valid_answer(self.basket)
|
bank_response = self.generate_bank_valid_answer(self.basket)
|
||||||
|
|||||||
Reference in New Issue
Block a user