mirror of
https://github.com/Sosokker/Inventory-Management-System.git
synced 2025-12-18 23:24:05 +01:00
Add Transaction related model
This commit is contained in:
parent
a8add047d0
commit
f2cfd9c333
17
inventory/migrations/0002_alter_inventory_options.py
Normal file
17
inventory/migrations/0002_alter_inventory_options.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Django 4.2.7 on 2023-11-18 12:03
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('inventory', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='inventory',
|
||||
options={'verbose_name_plural': 'Inventories'},
|
||||
),
|
||||
]
|
||||
@ -28,6 +28,9 @@ class Inventory(models.Model):
|
||||
min_stock = models.IntegerField()
|
||||
current_stock = models.IntegerField()
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = 'Inventories'
|
||||
|
||||
|
||||
class Item(models.Model):
|
||||
"""
|
||||
|
||||
64
transaction/migrations/0001_initial.py
Normal file
64
transaction/migrations/0001_initial.py
Normal file
@ -0,0 +1,64 @@
|
||||
# Generated by Django 4.2.7 on 2023-11-18 12:03
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('inventory', '0002_alter_inventory_options'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Customer',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('address', models.TextField()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Supplier',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('address', models.TextField()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Transfer',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('quantity', models.IntegerField()),
|
||||
('from_date_timestamp', models.DateTimeField()),
|
||||
('to_date_timestamp', models.DateTimeField()),
|
||||
('from_warehouse', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='transfer_from', to='inventory.warehouse')),
|
||||
('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='inventory.item')),
|
||||
('to_warehouse', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='transfer_to', to='inventory.warehouse')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Supply',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('quantity', models.IntegerField()),
|
||||
('arrive_date', models.DateField()),
|
||||
('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='inventory.item')),
|
||||
('supplier', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='transaction.supplier')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Order',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('order_date', models.DateField()),
|
||||
('quantity', models.IntegerField()),
|
||||
('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='transaction.customer')),
|
||||
('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='inventory.item')),
|
||||
],
|
||||
),
|
||||
]
|
||||
@ -1,3 +1,76 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
from inventory.models import Warehouse, Item
|
||||
|
||||
class Supplier(models.Model):
|
||||
"""
|
||||
The one who supply the item to the warehouse
|
||||
|
||||
:param name: Name of the supplier
|
||||
:param address: Address of the supplier
|
||||
"""
|
||||
name = models.CharField(max_length=255)
|
||||
address = models.TextField()
|
||||
|
||||
|
||||
class Supply(models.Model):
|
||||
"""
|
||||
Supply is a transaction that the supplier supply the item to the warehouse
|
||||
|
||||
:param supplier: Supplier that supply the item
|
||||
:param item: Item that is supplied
|
||||
:param quantity: Quantity of the item
|
||||
:param arrive_date: Date that the item arrive the warehouse
|
||||
"""
|
||||
supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE)
|
||||
item = models.ForeignKey(Item, on_delete=models.CASCADE)
|
||||
quantity = models.IntegerField()
|
||||
arrive_date = models.DateField()
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = 'Supplies'
|
||||
|
||||
|
||||
class Customer(models.Model):
|
||||
"""
|
||||
Customer is the one who buy the item from the warehouse
|
||||
|
||||
:param name: Name of the customer
|
||||
:param address: Address of the customer
|
||||
"""
|
||||
name = models.CharField(max_length=255)
|
||||
address = models.TextField()
|
||||
|
||||
|
||||
class Order(models.Model):
|
||||
"""
|
||||
Order is a transaction that the customer buy the item from the warehouse
|
||||
|
||||
:param customer: Customer that buy the item
|
||||
:param item: Item that is bought
|
||||
:param order_date: Date that the item is bought
|
||||
:param quantity: Quantity of the item
|
||||
"""
|
||||
customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
|
||||
item = models.ForeignKey(Item, on_delete=models.CASCADE)
|
||||
order_date = models.DateField()
|
||||
quantity = models.IntegerField()
|
||||
|
||||
|
||||
class Transfer(models.Model):
|
||||
"""
|
||||
Transfer is a transaction that the item is transfered from one warehouse to another
|
||||
|
||||
:param from_warehouse: Warehouse that the item is transfered from
|
||||
:param to_warehouse: Warehouse that the item is transfered to
|
||||
:param item: Item that is transfered
|
||||
:param quantity: Quantity of the item
|
||||
:param from_date_timestamp: Date that the item is transfered from the warehouse
|
||||
:param to_date_timestamp: Date that the item arrive new warehouse
|
||||
"""
|
||||
from_warehouse = models.ForeignKey(Warehouse, related_name='transfer_from', on_delete=models.CASCADE)
|
||||
to_warehouse = models.ForeignKey(Warehouse, related_name='transfer_to', on_delete=models.CASCADE)
|
||||
item = models.ForeignKey(Item, on_delete=models.CASCADE)
|
||||
quantity = models.IntegerField()
|
||||
from_date_timestamp = models.DateTimeField()
|
||||
to_date_timestamp = models.DateTimeField()
|
||||
Loading…
Reference in New Issue
Block a user