Skip to content

Commit

Permalink
updated total amount after deduction
Browse files Browse the repository at this point in the history
  • Loading branch information
jannat-349 committed Feb 26, 2024
1 parent af8b326 commit ba31305
Show file tree
Hide file tree
Showing 22 changed files with 8 additions and 185 deletions.
Binary file modified BharaHobe/db.sqlite3
Binary file not shown.
Binary file modified BharaHobe/payment/__pycache__/models.cpython-312.pyc
Binary file not shown.
Binary file modified BharaHobe/payment/__pycache__/test_monthly_payment.cpython-312.pyc
Binary file not shown.
Binary file modified BharaHobe/payment/__pycache__/views.cpython-312.pyc
Binary file not shown.
23 changes: 0 additions & 23 deletions BharaHobe/payment/migrations/0001_initial.py

This file was deleted.

18 changes: 0 additions & 18 deletions BharaHobe/payment/migrations/0002_payment_order_id.py

This file was deleted.

26 changes: 0 additions & 26 deletions BharaHobe/payment/migrations/0003_paymentmodel_delete_payment.py

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions BharaHobe/payment/migrations/0005_order.py

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions BharaHobe/payment/migrations/0007_paymentmodel_m_card_token.py

This file was deleted.

Empty file.
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.
Binary file not shown.
15 changes: 7 additions & 8 deletions BharaHobe/payment/models.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
from django.db import models

from django.db import models

class OrderModel(models.Model):
m_order_id = models.CharField(max_length=50, unique=True)
m_order_id = models.AutoField(primary_key=True)
m_items = models.TextField()
m_total_amount = models.DecimalField(max_digits=10, decimal_places=2)
m_notes = models.TextField(blank=True, null=True)

def __init__(self, *args, **kwargs):
super(OrderModel, self).__init__(*args, **kwargs)
if self.m_total_amount:
self.m_monthly_pay = self.m_total_amount // 6
else:
self.m_monthly_pay = None
if not self.m_monthly_pay:
if self.m_total_amount:
self.m_monthly_pay = self.m_total_amount // 6
else:
self.m_monthly_pay = 0

def __str__(self):
return f"Order #{self.m_order_id}"
Expand All @@ -28,4 +27,4 @@ class PaymentModel(models.Model):


def __str__(self):
return f"Payment #{self.id}"
return f"Payment #{self.id}"
1 change: 1 addition & 0 deletions BharaHobe/payment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def monthly_payment_view(request, order_id):
m_card_token=card_token
)
order.m_total_amount -= amount_to_pay
order.save()
return render(request, 'payment_success.html', {'payment': payment})
else:
return HttpResponseBadRequest("Please pay the exact amount.")
Expand Down

0 comments on commit ba31305

Please sign in to comment.