2020-05-31 12:08:26 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.urls import reverse_lazy
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
from core.models.invoices import Invoice, InvoiceItem
|
2020-05-31 12:08:26 +00:00
|
|
|
from core.views.generic import BackendListView, BackendUpdateView, BackendDeleteView, BackendCreateView
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
class InvoiceListView(BackendListView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/index.html"
|
|
|
|
model = Invoice
|
2020-05-31 12:08:26 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
2020-06-03 10:35:23 +00:00
|
|
|
context["title"] = "Invoice Settings"
|
2020-05-31 12:08:26 +00:00
|
|
|
return context
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
class InvoiceEditView(BackendUpdateView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/update.html"
|
|
|
|
model = Invoice
|
2020-06-03 10:35:23 +00:00
|
|
|
success_url = reverse_lazy("invoices")
|
2020-06-01 16:29:22 +00:00
|
|
|
fields = ["name", "logo", "address1", "address2", "zip", "city", "state", "country", "vat_id", "company_id"]
|
2020-05-31 12:08:26 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
2020-06-03 10:35:23 +00:00
|
|
|
context["title"] = "Edit Invoice"
|
2020-05-31 12:08:26 +00:00
|
|
|
return context
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
class InvoiceDeleteView(BackendDeleteView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/delete.html"
|
|
|
|
model = Invoice
|
2020-06-03 10:35:23 +00:00
|
|
|
success_url = reverse_lazy("invoices")
|
2020-05-31 12:08:26 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
2020-06-03 10:35:23 +00:00
|
|
|
context["title"] = "Delete Invoice"
|
2020-05-31 12:08:26 +00:00
|
|
|
return context
|
|
|
|
|
2020-06-02 15:58:20 +00:00
|
|
|
class InvoiceCreateView(BackendCreateView):
|
|
|
|
template_name = f"{settings.EXPEPHALON_BACKEND}/invoices/create.html"
|
|
|
|
model = Invoice
|
2020-06-03 10:35:23 +00:00
|
|
|
success_url = reverse_lazy("invoices")
|
2020-06-01 16:29:22 +00:00
|
|
|
fields = ["name", "logo", "address1", "address2", "zip", "city", "state", "country", "vat_id", "company_id"]
|
2020-05-31 12:08:26 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
2020-06-03 10:35:23 +00:00
|
|
|
context["title"] = "Create Invoice"
|
2020-05-31 12:08:26 +00:00
|
|
|
return context
|