main
parent
5d8243243e
commit
066f2e507b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
from billing.add import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('product', views.add_product, name='addproduct'),
|
||||
path('service', views.add_service, name='addservice'),
|
||||
path('order', views.add_order, name='addorder'),
|
||||
]
|
@ -0,0 +1,63 @@
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from osinacore.models import *
|
||||
from billing.models import *
|
||||
from django.http import JsonResponse, HttpResponse
|
||||
from django.template.loader import get_template
|
||||
from weasyprint import HTML
|
||||
|
||||
|
||||
def add_product (request, *args, **kwargs):
|
||||
item_types = ProjectType.objects.all().order_by('name')
|
||||
if request.method == 'POST':
|
||||
title = request.POST.get('title')
|
||||
description = request.POST.get('description')
|
||||
|
||||
item_type_id = request.POST.get('item_type')
|
||||
item_type = get_object_or_404(ProjectType, id=item_type_id)
|
||||
|
||||
amount = request.POST.get('amount')
|
||||
recurring = request.POST.get('recurring')
|
||||
|
||||
Item.objects.create(
|
||||
type='Product',
|
||||
title=title,
|
||||
description = description,
|
||||
item_type = item_type,
|
||||
amount = amount,
|
||||
recurring = recurring,
|
||||
)
|
||||
return redirect('items')
|
||||
context = {
|
||||
'item_types' : item_types,
|
||||
|
||||
}
|
||||
return render(request, 'add_templates/add-product.html', context)
|
||||
|
||||
|
||||
|
||||
def add_service (request, *args, **kwargs):
|
||||
context = {
|
||||
|
||||
}
|
||||
return render(request, 'add_templates/add-service.html', context)
|
||||
|
||||
|
||||
def add_order (request, *args, **kwargs):
|
||||
customers = CustomerProfile.objects.all().order_by('-id')
|
||||
|
||||
context = {
|
||||
'customers': customers,
|
||||
}
|
||||
|
||||
return render(request, 'add_templates/add-order.html', context)
|
||||
|
||||
|
||||
def add_invoice_pdf(request):
|
||||
template = get_template('details_templates/invoice-details.html')
|
||||
context = {}
|
||||
html_string = template.render(context)
|
||||
|
||||
pdf = HTML(string=html_string).write_pdf()
|
||||
response = HttpResponse(pdf, content_type='application/pdf')
|
||||
response['Content-Disposition'] = 'attachment; filename="my_pdf.pdf"'
|
||||
return response
|
@ -0,0 +1,22 @@
|
||||
# Generated by Django 4.2.5 on 2024-04-12 17:48
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('billing', '0025_remove_item_project_item_customer'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='item',
|
||||
old_name='type',
|
||||
new_name='item_type',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='order',
|
||||
name='paid',
|
||||
),
|
||||
]
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2.5 on 2024-04-12 17:48
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('billing', '0026_rename_type_item_item_type_remove_order_paid'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='item',
|
||||
name='type',
|
||||
field=models.CharField(choices=[('Product', 'Product'), ('Service', 'Service')], max_length=200, null=True),
|
||||
),
|
||||
]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,36 +1,20 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from django.urls import path, include
|
||||
from django.conf.urls import handler404
|
||||
from django.conf.urls.static import static
|
||||
from django.conf import settings
|
||||
from billing import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
|
||||
path('add/', include('billing.add.urls')),
|
||||
|
||||
# LISTING
|
||||
path('items', views.items, name='items'),
|
||||
path('orders', views.orders, name='orders'),
|
||||
path('invoices', views.invoices, name='invoices'),
|
||||
|
||||
|
||||
# ADD
|
||||
path('add-product', views.add_product, name='addproduct'),
|
||||
path('add-service', views.add_service, name='addservice'),
|
||||
path('add-order', views.add_order, name='addorder'),
|
||||
|
||||
|
||||
path('fetch-customer-items/<int:customer_id>/', views.fetch_customer_items, name='fetch_customer_items'),
|
||||
path('fetch-invoice-details/<int:invoice_id>/', views.fetch_invoice_details, name='fetchinvoicedetails'),
|
||||
|
||||
|
||||
# DETAILS
|
||||
path('invoice-details/<int:invoice_id>/', views.invoice_details, name='invoicedetails'),
|
||||
|
||||
path('generate-pdf/', views.generate_pdf, name='generate-pdf'),
|
||||
|
||||
|
||||
|
||||
path('fetch-customer-items/<int:customer_id>/', views.fetch_customer_items, name='fetch_customer_items'),
|
||||
|
||||
]
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue