Add option to include prefix and invoice number in payment reference (#1848)

This commit is contained in:
julia-luna
2020-11-11 14:27:43 +01:00
committed by GitHub
parent 8c63f2159c
commit 62a0dd2541
2 changed files with 19 additions and 5 deletions

View File

@@ -111,10 +111,18 @@ class BankTransfer(BasePaymentProvider):
required=False
)),
('omit_hyphen', forms.BooleanField(
label=_('Do not include a hyphen in the payment reference.'),
label=_('Do not include hyphens in the payment reference.'),
help_text=_('This is required in some countries.'),
required=False
)),
('include_invoice_number', forms.BooleanField(
label=_('Include invoice number in the payment reference.'),
required=False
)),
('prefix', forms.CharField(
label=_('Prefix for the payment reference'),
required=False,
))
])
@property
@@ -227,10 +235,16 @@ class BankTransfer(BasePaymentProvider):
return template.render(ctx)
def _code(self, order):
prefix = self.settings.get('prefix', default='')
li = order.invoices.last()
invoice_number = li.number if self.settings.get('include_invoice_number', as_type=bool) and li else ''
code = " ".join((prefix, order.full_code, invoice_number)).strip(" ")
if self.settings.get('omit_hyphen', as_type=bool):
return self.event.slug.upper() + order.code
else:
return order.full_code
code = code.replace('-', '')
return code
def shred_payment_info(self, obj):
if not obj.info_data:

View File

@@ -227,7 +227,7 @@ class OrderDetails(EventViewMixin, OrderDetailMixin, CartMixin, TicketPageMixin,
if lp and lp.state not in (OrderPayment.PAYMENT_STATE_CONFIRMED, OrderPayment.PAYMENT_STATE_REFUNDED,
OrderPayment.PAYMENT_STATE_CANCELED):
ctx['last_payment'] = self.order.payments.last()
ctx['last_payment'] = lp
pp = lp.payment_provider
ctx['last_payment_info'] = pp.payment_pending_render(self.request, ctx['last_payment'])