diff --git a/.DS_Store b/.DS_Store index f1fcd393..b10de2d5 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/osinaweb/.DS_Store b/osinaweb/.DS_Store index 2e84bc6a..2dc331ea 100644 Binary files a/osinaweb/.DS_Store and b/osinaweb/.DS_Store differ diff --git a/osinaweb/billing/.DS_Store b/osinaweb/billing/.DS_Store new file mode 100644 index 00000000..a7b7da6a Binary files /dev/null and b/osinaweb/billing/.DS_Store differ diff --git a/osinaweb/billing/__pycache__/models.cpython-310.pyc b/osinaweb/billing/__pycache__/models.cpython-310.pyc index 9e7b5544..c7c0d551 100644 Binary files a/osinaweb/billing/__pycache__/models.cpython-310.pyc and b/osinaweb/billing/__pycache__/models.cpython-310.pyc differ diff --git a/osinaweb/billing/__pycache__/urls.cpython-310.pyc b/osinaweb/billing/__pycache__/urls.cpython-310.pyc index dfe42e93..50de5028 100644 Binary files a/osinaweb/billing/__pycache__/urls.cpython-310.pyc and b/osinaweb/billing/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/billing/__pycache__/views.cpython-310.pyc b/osinaweb/billing/__pycache__/views.cpython-310.pyc index 70bf2185..9d21722b 100644 Binary files a/osinaweb/billing/__pycache__/views.cpython-310.pyc and b/osinaweb/billing/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/billing/add/__pycache__/urls.cpython-310.pyc b/osinaweb/billing/add/__pycache__/urls.cpython-310.pyc new file mode 100644 index 00000000..0092be93 Binary files /dev/null and b/osinaweb/billing/add/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/billing/add/__pycache__/views.cpython-310.pyc b/osinaweb/billing/add/__pycache__/views.cpython-310.pyc new file mode 100644 index 00000000..2860681e Binary files /dev/null and b/osinaweb/billing/add/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/billing/add/urls.py b/osinaweb/billing/add/urls.py new file mode 100644 index 00000000..c29906c6 --- /dev/null +++ b/osinaweb/billing/add/urls.py @@ -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'), +] diff --git a/osinaweb/billing/add/views.py b/osinaweb/billing/add/views.py new file mode 100644 index 00000000..48cff91f --- /dev/null +++ b/osinaweb/billing/add/views.py @@ -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 \ No newline at end of file diff --git a/osinaweb/billing/delete/urls.py b/osinaweb/billing/delete/urls.py new file mode 100644 index 00000000..e69de29b diff --git a/osinaweb/billing/delete/views.py b/osinaweb/billing/delete/views.py new file mode 100644 index 00000000..e69de29b diff --git a/osinaweb/billing/edit/urls.py b/osinaweb/billing/edit/urls.py new file mode 100644 index 00000000..e69de29b diff --git a/osinaweb/billing/edit/views.py b/osinaweb/billing/edit/views.py new file mode 100644 index 00000000..e69de29b diff --git a/osinaweb/billing/migrations/0026_rename_type_item_item_type_remove_order_paid.py b/osinaweb/billing/migrations/0026_rename_type_item_item_type_remove_order_paid.py new file mode 100644 index 00000000..a31aa7b2 --- /dev/null +++ b/osinaweb/billing/migrations/0026_rename_type_item_item_type_remove_order_paid.py @@ -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', + ), + ] diff --git a/osinaweb/billing/migrations/0027_item_type.py b/osinaweb/billing/migrations/0027_item_type.py new file mode 100644 index 00000000..b4e3697c --- /dev/null +++ b/osinaweb/billing/migrations/0027_item_type.py @@ -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), + ), + ] diff --git a/osinaweb/billing/migrations/__pycache__/0026_rename_type_item_item_type_remove_order_paid.cpython-310.pyc b/osinaweb/billing/migrations/__pycache__/0026_rename_type_item_item_type_remove_order_paid.cpython-310.pyc new file mode 100644 index 00000000..d0d88df0 Binary files /dev/null and b/osinaweb/billing/migrations/__pycache__/0026_rename_type_item_item_type_remove_order_paid.cpython-310.pyc differ diff --git a/osinaweb/billing/migrations/__pycache__/0027_item_type.cpython-310.pyc b/osinaweb/billing/migrations/__pycache__/0027_item_type.cpython-310.pyc new file mode 100644 index 00000000..42efbe7f Binary files /dev/null and b/osinaweb/billing/migrations/__pycache__/0027_item_type.cpython-310.pyc differ diff --git a/osinaweb/billing/models.py b/osinaweb/billing/models.py index 1ad96577..0df4aa70 100644 --- a/osinaweb/billing/models.py +++ b/osinaweb/billing/models.py @@ -17,10 +17,11 @@ class Item(models.Model): ('Product', 'Product'), ('Service', 'Service'), ) + type = models.CharField(max_length=200, choices=TYPE, null=True) title = models.CharField(max_length=200) description = models.TextField(blank=True) customer = models.ForeignKey(CustomerProfile, null=True, blank=True, on_delete=models.CASCADE) - type = models.ForeignKey(ProjectType, on_delete=models.CASCADE, null=True, blank=True) + item_type = models.ForeignKey(ProjectType, on_delete=models.CASCADE, null=True, blank=True) amount = models.FloatField(null=True) recurring = models.BooleanField(default=False) def __str__(self): @@ -38,7 +39,6 @@ class Order(models.Model): status = models.CharField(max_length=200, choices=STATUS, default='None') order_id = models.CharField(max_length=100, null=True, blank=True) due_date = models.DateField(null=True) - paid = models.BooleanField(null=True, default=False) @property def get_cart_total(self): orderitems = self.orderitem_set.all() diff --git a/osinaweb/billing/templates/.DS_Store b/osinaweb/billing/templates/.DS_Store new file mode 100644 index 00000000..efbd10e1 Binary files /dev/null and b/osinaweb/billing/templates/.DS_Store differ diff --git a/osinaweb/billing/templates/add_templates/add-product.html b/osinaweb/billing/templates/add_templates/add-product.html index 23c71010..00551e91 100644 --- a/osinaweb/billing/templates/add_templates/add-product.html +++ b/osinaweb/billing/templates/add_templates/add-product.html @@ -8,55 +8,48 @@ Add Product -