docs: def create_from_registration(cls, reg, **kwargs):
          '''
          Handles the creation of an Invoice as well as one InvoiceItem per
          assodciated TemporaryEventRegistration or registration.  Also handles taxes
          appropriately.
          '''
          submissionUser = kwargs.pop('submissionUser', None)
          collectedByUser = kwargs.pop('collectedByUser', None)
          status = kwargs.pop('status',Invoice.PaymentStatus.unpaid)
  
          new_invoice = cls(
              firstName=reg.firstName,
              lastName=reg.lastName,
              email=reg.email,
              grossTotal=reg.totalPrice,
              total=reg.priceWithDiscount,
              submissionUser=submissionUser,
              collectedByUser=collectedByUser,
              buyerPaysSalesTax=getConstant('registration__buyerPaysSalesTax'),
              status=status,
              data=kwargs,
          )
  
          if isinstance(reg, Registration):
              new_invoice.finalRegistration = reg
              ter_set = reg.eventregistration_set.all()
          elif isinstance(reg, TemporaryRegistration):
              new_invoice.temporaryRegistration = reg
              ter_set = reg.temporaryeventregistration_set.all()
          else:
              raise ValueError('Object passed is not a registration.')
  
          new_invoice.calculateTaxes()
          new_invoice.save()
  
          # Now, create InvoiceItem records for each EventRegistration
          for ter in ter_set:
              # Discounts and vouchers are always applied equally to all items at initial
              # invoice creation.
              item_kwargs = {
                  'invoice': new_invoice,
                  'grossTotal': ter.price,
              }
  
              if new_invoice.grossTotal > 0:
                  item_kwargs.update({
                      'total': ter.price * (new_invoice.total / new_invoice.grossTotal),
                      'taxes': new_invoice.taxes * (ter.price / new_invoice.grossTotal),
                      'fees': new_invoice.fees * (ter.price / new_invoice.grossTotal),
                  })
              else:
                  item_kwargs.update({
                      'total': ter.price,
                      'taxes': new_invoice.taxes,
                      'fees': new_invoice.fees,
                  })
  
              if isinstance(ter,TemporaryEventRegistration):
                  item_kwargs['temporaryEventRegistration'] = ter
              elif isinstance(ter,EventRegistration):
                  item_kwargs['finalEventRegistration'] = ter
  
              this_item = InvoiceItem(**item_kwargs)
              this_item.save()
  
          return new_invoice