def invoice_address(self): iapk = self.request.session.get('invoice_address') if not iapk: return InvoiceAddress() try: return InvoiceAddress.objects.get(pk=iapk, order__isnull=True) except InvoiceAddress.DoesNotExist: return InvoiceAddress()
def invoice_address(self): if not hasattr(self.request, '_checkout_flow_invoice_address'): iapk = self.cart_session.get('invoice_address') if not iapk: self.request._checkout_flow_invoice_address = InvoiceAddress() else: try: self.request._checkout_flow_invoice_address = InvoiceAddress.objects.get(pk=iapk, order__isnull=True) except InvoiceAddress.DoesNotExist: self.request._checkout_flow_invoice_address = InvoiceAddress() return self.request._checkout_flow_invoice_address
def invoice_address(self): try: return self.order.invoice_address except InvoiceAddress.DoesNotExist: return InvoiceAddress(order=self.order)
def _create_order(event: Event, email: str, positions: List[CartPosition], now_dt: datetime, payment_provider: BasePaymentProvider, locale: str = None, address: InvoiceAddress = None, meta_info: dict = None): from datetime import time fees = _get_fees(positions, payment_provider, address, meta_info, event) total = sum([c.price for c in positions]) + sum([c.value for c in fees]) tz = pytz.timezone(event.settings.timezone) exp_by_date = now_dt.astimezone(tz) + timedelta( days=event.settings.get('payment_term_days', as_type=int)) exp_by_date = exp_by_date.astimezone(tz).replace(hour=23, minute=59, second=59, microsecond=0) if event.settings.get('payment_term_weekdays'): if exp_by_date.weekday() == 5: exp_by_date += timedelta(days=2) elif exp_by_date.weekday() == 6: exp_by_date += timedelta(days=1) expires = exp_by_date term_last = event.settings.get('payment_term_last', as_type=RelativeDateWrapper) if term_last: if event.has_subevents: term_last = min([ term_last.datetime(se).date() for se in event.subevents.filter( id__in=[p.subevent_id for p in positions]) ]) else: term_last = term_last.datetime(event).date() term_last = make_aware( datetime.combine(term_last, time(hour=23, minute=59, second=59)), tz) if term_last < expires: expires = term_last with transaction.atomic(): order = Order.objects.create( status=Order.STATUS_PENDING, event=event, email=email, datetime=now_dt, expires=expires, locale=locale, total=total, payment_provider=payment_provider.identifier, meta_info=json.dumps(meta_info or {}), ) if address: if address.order is not None: address.pk = None address.order = order address.save() order.save() for fee in fees: fee.order = order fee._calculate_tax() fee.save() OrderPosition.transform_cart_positions(positions, order) order.log_action('pretix.event.order.placed') order_placed.send(event, order=order) return order