商品进销存管理系统是一种用于管理商品进货、销售和库存的软件。它可以帮助商家更好地了解商品的流动情况,提高经营效率。以下是一个简单的Python商品进销存管理系统的实现:
```python
class Product:
def __init__(self, name, price):
self.name = name
self.price = price
self.stock = 0
class Inventory:
def __init__(self):
self.products = {}
def add_product(self, product):
if product.name in self.products:
print("产品已存在,请重新输入")
else:
self.products[product.name] = product
print("产品添加成功")
def remove_product(self, product_name):
if product_name in self.products:
del self.products[product_name]
print("产品删除成功")
else:
print("产品不存在")
def update_product(self, product_name, new_price):
if product_name in self.products:
self.products[product_name].price = new_price
print("价格更新成功")
else:
print("产品不存在")
def get_product_info(self, product_name):
if product_name in self.products:
return self.products[product_name]
else:
print("产品不存在")
return None
class Sales:
def __init__(self):
self.inventory = Inventory()
def add_sales(self, product_name, quantity):
product = self.inventory.get_product_info(product_name)
if product is not None:
product.stock += quantity
print("销售成功")
else:
print("产品不存在")
def remove_sales(self, product_name, quantity):
product = self.inventory.get_product_info(product_name)
if product is not None:
if product.stock >= quantity:
product.stock -= quantity
print("销售成功")
else:
print("库存不足,无法销售")
else:
print("产品不存在")
def update_sales(self, product_name, quantity):
product = self.inventory.get_product_info(product_name)
if product is not None:
if product.stock >= quantity:
product.stock -= quantity
print("销售成功")
else:
print("库存不足,无法销售")
else:
print("产品不存在")
def get_sales_info(self, product_name):
product = self.inventory.get_product_info(product_name)
if product is not None:
return f"{product.name} 销售数量:{product.stock}"
else:
return "产品不存在"
```
这个简单的商品进销存管理系统包括以下功能:
1. 添加商品:可以添加新的商品信息,包括名称、价格和库存。
2. 删除商品:可以根据商品名称删除商品。
3. 更新商品价格:可以修改商品的价格。
4. 获取商品信息:可以查询商品的名称、价格和库存。
5. 销售商品:可以根据商品名称和数量进行销售操作,并更新库存。
6. 查看销售信息:可以查看某个商品的销售数量。