Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Django Help Needed urgently
#1
I am trying to create a simple inventory app using Django. My project came to a stand still when I couldn't find a solution for calculating opening and closing balances on the fly/dynamically. I tried for days researching on the web but no progress yet. If anyone could help i will appreciate.

All I need is a query to calculate opening and closing balances dynamically.

My Models:

class Item(models.Model):
name = models.CharField(max_length=30)
buying_price = models.PositiveIntegerField()
selling_price = models.PositiveIntegerField()
quantity = models.PositiveIntegerField()

def __str__(self):
    return self.name    
class SalesSheet(models.Model):
txn_date = models.DateField()
item = models.ForeignKey(Item, on_delete=models.CASCADE)
purchases = models.PositiveIntegerField()
sales = models.PositiveIntegerField()
What I want after posting purchases and sales is an output like this

Output:
id date item opening purchases sales closing 1 1-1-19 abc 10 20 5 25 2 2-12-19 def 25 20 10 35 3 3-1-19 abc 25 10 25 10 4 4-1-19 def 35 10 30 15 5 7-1-19 abc 10 0 0 10 6 9-1-19 def 15 0 5 10
and so on.....

I am using item.quantity to store opening stock for the first time only.

Take into consideration that there will be different items and also back dated entries.

help me guys.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,315 Jun-30-2019, 12:21 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020