def test_rebuilding(env): event, order = env inv = generate_invoice(order) inv2 = regenerate_invoice(inv) assert inv.order == inv2.order inv3 = generate_cancellation(inv) inv4 = regenerate_invoice(inv3) assert inv3.order == inv4.order
def regenerate(self, request, **kwarts): inv = self.get_object() if inv.canceled: raise ValidationError('The invoice has already been canceled.') else: inv = regenerate_invoice(inv) inv.order.log_action( 'pretix.event.order.invoice.regenerated', data={'invoice': inv.pk}, user=self.request.user, api_token=(self.request.auth if isinstance( self.request.auth, TeamAPIToken) else None), ) return Response(status=204)
def post(self, *args, **kwargs): try: inv = self.order.invoices.get(pk=kwargs.get('id')) except Order.DoesNotExist: messages.error(self.request, _('Unknown invoice.')) else: if inv.canceled: messages.error(self.request, _('The invoice has already been canceled.')) else: inv = regenerate_invoice(inv) self.order.log_action('pretix.event.order.invoice.regenerated', user=self.request.user, data={ 'invoice': inv.pk }) messages.success(self.request, _('The invoice has been regenerated.')) return redirect(self.get_order_url())
def post(self, *args, **kwargs): try: inv = self.order.invoices.get(pk=kwargs.get('id')) except Invoice.DoesNotExist: messages.error(self.request, _('Unknown invoice.')) else: if inv.canceled: messages.error(self.request, _('The invoice has already been canceled.')) else: inv = regenerate_invoice(inv) self.order.log_action('pretix.event.order.invoice.regenerated', user=self.request.user, data={ 'invoice': inv.pk }) messages.success(self.request, _('The invoice has been regenerated.')) return redirect(self.get_order_url())
def regenerate(self, request, **kwarts): inv = self.get_object() if inv.canceled: raise ValidationError('The invoice has already been canceled.') elif inv.shredded: raise PermissionDenied( 'The invoice file is no longer stored on the server.') else: inv = regenerate_invoice(inv) inv.order.log_action( 'pretix.event.order.invoice.regenerated', data={'invoice': inv.pk}, user=self.request.user, auth=self.request.auth, ) return Response(status=204)
def regenerate(self, request, **kwarts): inv = self.get_object() if inv.canceled: raise ValidationError('The invoice has already been canceled.') elif inv.shredded: raise PermissionDenied('The invoice file is no longer stored on the server.') else: inv = regenerate_invoice(inv) inv.order.log_action( 'pretix.event.order.invoice.regenerated', data={ 'invoice': inv.pk }, user=self.request.user, auth=self.request.auth, ) return Response(status=204)