# Path: registrasion/models/commerce.py
# class Cart(models.Model):
#     class Meta:
# class ProductItem(models.Model):
#     class Meta:
# class DiscountItem(models.Model):
#     class Meta:
# class Invoice(models.Model):
#     class Meta:
# class LineItem(models.Model):
#     class Meta:
# class PaymentBase(models.Model):
#     class Meta:
# class ManualPayment(PaymentBase):
#     class Meta:
# class CreditNote(PaymentBase):
#     class Meta:
# class CleanOnSave(object):
# class CreditNoteApplication(CleanOnSave, PaymentBase):
#     class Meta:
# class CreditNoteRefund(CleanOnSave, models.Model):
# class ManualCreditNoteRefund(CreditNoteRefund):
#     class Meta:
#     def __str__(self):
#     def reserved_carts(cls):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def clean(self):
#     def is_unpaid(self):
#     def is_void(self):
#     def is_paid(self):
#     def is_refunded(self):
#     def total_payments(self):
#     def balance_due(self):
#     def __str__(self):
#     def total_price(self):
#     def __str__(self):
#     def unclaimed(cls):
#     def refunded(cls):
#     def status(self):
#     def is_unclaimed(self):
#     def value(self):
#     def save(self, *a, **k):
#     def clean(self):
#     def clean(self):
#     STATUS_ACTIVE = 1
#     STATUS_PAID = 2
#     STATUS_RELEASED = 3
#     STATUS_TYPES = [
#         (STATUS_ACTIVE, _("Active")),
#         (STATUS_PAID, _("Paid")),
#         (STATUS_RELEASED, _("Released")),
#     ]
#     STATUS_UNPAID = 1
#     STATUS_PAID = 2
#     STATUS_REFUNDED = 3
#     STATUS_VOID = 4
#     STATUS_TYPES = [
#         (STATUS_UNPAID, _("Unpaid")),
#         (STATUS_PAID, _("Paid")),
#         (STATUS_REFUNDED, _("Refunded")),
#         (STATUS_VOID, _("VOID")),
#     ]
# 
# Path: registrasion/controllers/for_id.py
# class ForId(object):
#     ''' Mixin class that gives you new classmethods: for_id for_id_or_404.
#     These let you retrieve an instance of the class by specifying the model ID.
# 
#     Your subclass must define __MODEL__ as a class attribute. This will be the
#     model class that we wrap. There must also be a constructor that takes a
#     single argument: the instance of the model that we are controlling. '''
# 
#     @classmethod
#     def for_id(cls, id_):
#         id_ = int(id_)
#         obj = cls.__MODEL__.objects.get(pk=id_)
#         return cls(obj)
# 
#     @classmethod
#     def for_id_or_404(cls, id_):
#         try:
#             return cls.for_id(id_)
#         except ObjectDoesNotExist:
#             raise Http404()


import datetime
from django.db import transaction
from registrasion.models import commerce
from .for_id import ForId
        from .invoice import InvoiceController
        from .invoice import InvoiceController





class CreditNoteController(ForId, object):

    __MODEL__ = commerce.CreditNote

    def __init__(self, credit_note):
        self.credit_note = credit_note

    @classmethod
    def generate_from_invoice(cls, invoice, value):
        ''' Generates a credit note of the specified value and pays it against
        the given invoice. You need to call InvoiceController.update_status()
        to set the status correctly, if appropriate. '''


# Path: registrasion/models/commerce.py
# class Cart(models.Model):
#     class Meta:
# class ProductItem(models.Model):
#     class Meta:
# class DiscountItem(models.Model):
#     class Meta:
# class Invoice(models.Model):
#     class Meta:
# class LineItem(models.Model):
#     class Meta:
# class PaymentBase(models.Model):
#     class Meta:
# class ManualPayment(PaymentBase):
#     class Meta:
# class CreditNote(PaymentBase):
#     class Meta:
# class CleanOnSave(object):
# class CreditNoteApplication(CleanOnSave, PaymentBase):
#     class Meta:
# class CreditNoteRefund(CleanOnSave, models.Model):
# class ManualCreditNoteRefund(CreditNoteRefund):
#     class Meta:
#     def __str__(self):
#     def reserved_carts(cls):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def clean(self):
#     def is_unpaid(self):
#     def is_void(self):
#     def is_paid(self):
#     def is_refunded(self):
#     def total_payments(self):
#     def balance_due(self):
#     def __str__(self):
#     def total_price(self):
#     def __str__(self):
#     def unclaimed(cls):
#     def refunded(cls):
#     def status(self):
#     def is_unclaimed(self):
#     def value(self):
#     def save(self, *a, **k):
#     def clean(self):
#     def clean(self):
#     STATUS_ACTIVE = 1
#     STATUS_PAID = 2
#     STATUS_RELEASED = 3
#     STATUS_TYPES = [
#         (STATUS_ACTIVE, _("Active")),
#         (STATUS_PAID, _("Paid")),
#         (STATUS_RELEASED, _("Released")),
#     ]
#     STATUS_UNPAID = 1
#     STATUS_PAID = 2
#     STATUS_REFUNDED = 3
#     STATUS_VOID = 4
#     STATUS_TYPES = [
#         (STATUS_UNPAID, _("Unpaid")),
#         (STATUS_PAID, _("Paid")),
#         (STATUS_REFUNDED, _("Refunded")),
#         (STATUS_VOID, _("VOID")),
#     ]
# 
# Path: registrasion/controllers/for_id.py
# class ForId(object):
#     ''' Mixin class that gives you new classmethods: for_id for_id_or_404.
#     These let you retrieve an instance of the class by specifying the model ID.
# 
#     Your subclass must define __MODEL__ as a class attribute. This will be the
#     model class that we wrap. There must also be a constructor that takes a
#     single argument: the instance of the model that we are controlling. '''
# 
#     @classmethod
#     def for_id(cls, id_):
#         id_ = int(id_)
#         obj = cls.__MODEL__.objects.get(pk=id_)
#         return cls(obj)
# 
#     @classmethod
#     def for_id_or_404(cls, id_):
#         try:
#             return cls.for_id(id_)
#         except ObjectDoesNotExist:
#             raise Http404()


# Path: registrasion/controllers/credit_note.py
import datetime
from django.db import transaction
from registrasion.models import commerce
from .for_id import ForId
        from .invoice import InvoiceController
        from .invoice import InvoiceController






class CreditNoteController(ForId, object):

    __MODEL__ = commerce.CreditNote

    def __init__(self, credit_note):
        self.credit_note = credit_note

    @classmethod
    def generate_from_invoice(cls, invoice, value):
        ''' Generates a credit note of the specified value and pays it against
        the given invoice. You need to call InvoiceController.update_status()
        to set the status correctly, if appropriate. '''


        credit_note = commerce.CreditNote.objects.create(