Commit c46628bd authored by frekk's avatar frekk

Merge remote-tracking branch 'origin/master' into frekk-testing

parents 8bf82864 bf5def24
...@@ -13,7 +13,7 @@ from memberdb.models import Membership, MEMBERSHIP_TYPES ...@@ -13,7 +13,7 @@ from memberdb.models import Membership, MEMBERSHIP_TYPES
from .models import MembershipPayment, CardPayment from .models import MembershipPayment, CardPayment
from . import payments from . import payments
from .payments import try_capture_payment from .payments import try_capture_payment, log
from .dispense import get_item_price from .dispense import get_item_price
class PaymentFormMixin: class PaymentFormMixin:
...@@ -94,9 +94,11 @@ class MembershipPaymentView(MemberAccessMixin, PaymentFormMixin, DetailView): ...@@ -94,9 +94,11 @@ class MembershipPaymentView(MemberAccessMixin, PaymentFormMixin, DetailView):
) )
except Membership.DoesNotExist as e: except Membership.DoesNotExist as e:
# no unpaid membership found, return # no unpaid membership found, return
log.warning("could not find unpaid membership with id %s" % self.kwargs['pk'])
return None return None
except MembershipPayment.DoesNotExist as e: except MembershipPayment.DoesNotExist as e:
# found an unpaid membership, but no payment record exists yet # found an unpaid membership, but no payment record exists yet
log.info("creating membership payment for membership id %s" % self.kwargs['pk'])
return create_membership_payment(ms) return create_membership_payment(ms)
return payment return payment
...@@ -126,10 +128,10 @@ class MembershipPaymentView(MemberAccessMixin, PaymentFormMixin, DetailView): ...@@ -126,10 +128,10 @@ class MembershipPaymentView(MemberAccessMixin, PaymentFormMixin, DetailView):
def create_membership_payment(membership, commit=True): def create_membership_payment(membership, commit=True):
""" creates a MembershipPayment object for the given membership """ """ creates a MembershipPayment object for the given membership """
# get the amount from dispense # get the amount from dispense
price = get_item_price(membership.membership_type) price = get_item_price(membership.get_dispense_item())
if (price is None or price == 0): if (price is None or price == 0):
return None return None
desc = MEMBERSHIP_TYPES[membership.membership_type]['desc'] desc = membership.get_pretty_type()
payment = MembershipPayment(description=desc, amount=price, membership=membership) payment = MembershipPayment(description=desc, amount=price, membership=membership)
if (commit): if (commit):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment