![]() |
Django Help Needed urgently - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Django Help Needed urgently (/thread-15884.html) |
Django Help Needed urgently - mahmood - Feb-05-2019 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 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. |