diff --git a/osinaweb/billing/__pycache__/models.cpython-310.pyc b/osinaweb/billing/__pycache__/models.cpython-310.pyc index 07fab5b8..2b2265b6 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/add/__pycache__/views.cpython-310.pyc b/osinaweb/billing/add/__pycache__/views.cpython-310.pyc index c39c66d7..6eca4687 100644 Binary files a/osinaweb/billing/add/__pycache__/views.cpython-310.pyc and b/osinaweb/billing/add/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/billing/add/views.py b/osinaweb/billing/add/views.py index b6a8a700..91ecc738 100644 --- a/osinaweb/billing/add/views.py +++ b/osinaweb/billing/add/views.py @@ -125,12 +125,13 @@ def add_invoice_pdf(request, order_id): order = get_object_or_404(Order, id=order_id) current_year = str(timezone.now().year)[-2:] - last_invoice = Invoice.objects.filter(invoice_number__startswith=current_year).order_by('-invoice_number').first() + last_invoice = Invoice.objects.all().last() if last_invoice: last_invoice_number = int(last_invoice.invoice_number.split('-')[1].split('+')[0]) - new_invoice_number = f"${current_year}-{last_invoice_number + 1}" + new_invoice_number = f"$0{current_year}-{last_invoice_number + 1}" else: - new_invoice_number = f"${current_year}-1425" + new_invoice_number = f"$0{current_year}-1425" + invoice = Invoice.objects.create( diff --git a/osinaweb/billing/models.py b/osinaweb/billing/models.py index f99a8b46..327f65b8 100644 --- a/osinaweb/billing/models.py +++ b/osinaweb/billing/models.py @@ -77,27 +77,6 @@ class OrderItem(models.Model): total = self.item.amount total = round(total, 2) return total - def save(self, *args, **kwargs): - if self.purchased_at: - try: - customer_email = self.order.customer.user.email - plan_name = self.item.title - - payload = { - 'email': customer_email, - 'plan': plan_name - } - response = requests.post('https://osimenu.com/api/create-subscription/', data=payload) - - if response.status_code == 201: - print('Subscription created successfully') - else: - print('Failed to create subscription') - except Exception as e: - print(f'Error creating subscription: {e}') - - super(OrderItem, self).save(*args, **kwargs) - class Invoice(models.Model): @@ -110,12 +89,12 @@ class Invoice(models.Model): def save(self, *args, **kwargs): if not self.invoice_number: current_year = str(timezone.now().year)[-2:] - last_invoice = Invoice.objects.filter(invoice_number__startswith=current_year).order_by('-invoice_number').first() + last_invoice = Invoice.objects.all().last() if last_invoice: last_invoice_number = int(last_invoice.invoice_number.split('-')[1].split('+')[0]) - new_invoice_number = f"${current_year}-{last_invoice_number + 1}" + new_invoice_number = f"$0{current_year}-{last_invoice_number + 1}" else: - new_invoice_number = f"${current_year}-1425" + new_invoice_number = f"$0{current_year}-1425" self.invoice_number = new_invoice_number super().save(*args, **kwargs) diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 646d2de2..63086987 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/static/images/generated_invoices/invoice_024-1426.pdf b/osinaweb/static/images/generated_invoices/invoice_024-1426.pdf new file mode 100644 index 00000000..9046b31f Binary files /dev/null and b/osinaweb/static/images/generated_invoices/invoice_024-1426.pdf differ diff --git a/osinaweb/static/images/generated_invoices/invoice_24-1425_GsdpOOM.pdf b/osinaweb/static/images/generated_invoices/invoice_24-1425_GsdpOOM.pdf new file mode 100644 index 00000000..1c247550 Binary files /dev/null and b/osinaweb/static/images/generated_invoices/invoice_24-1425_GsdpOOM.pdf differ diff --git a/osinaweb/static/images/generated_invoices/invoice_24-1425_ROjXnJ9.pdf b/osinaweb/static/images/generated_invoices/invoice_24-1425_ROjXnJ9.pdf new file mode 100644 index 00000000..b84e6590 Binary files /dev/null and b/osinaweb/static/images/generated_invoices/invoice_24-1425_ROjXnJ9.pdf differ