diff --git a/inventory-backend/app/api/v1/inbound/buy.py b/inventory-backend/app/api/v1/inbound/buy.py index 4b1f8ac..7b14a88 100644 --- a/inventory-backend/app/api/v1/inbound/buy.py +++ b/inventory-backend/app/api/v1/inbound/buy.py @@ -52,6 +52,7 @@ def filter_item_by_permissions(item_dict, user_permissions): 'inspection_status': 'inbound_buy:inspection_status', 'warehouse_location': 'inbound_buy:warehouse_location', 'unit_price': 'inbound_buy:unit_price', + 'post_tax_unit_price': 'inbound_buy:post_tax_unit_price', 'tax_rate': 'inbound_buy:tax_rate', 'total_price': 'inbound_buy:total_price', 'currency': 'inbound_buy:currency', @@ -166,6 +167,7 @@ def submit(): 'inspection_status': 'inbound_buy:inspection_status', 'warehouse_location': 'inbound_buy:warehouse_location', 'unit_price': 'inbound_buy:unit_price', + 'post_tax_unit_price': 'inbound_buy:post_tax_unit_price', 'tax_rate': 'inbound_buy:tax_rate', 'total_price': 'inbound_buy:total_price', 'currency': 'inbound_buy:currency', @@ -230,6 +232,7 @@ def update_buy(id): 'inspection_status': 'inbound_buy:inspection_status', 'warehouse_location': 'inbound_buy:warehouse_location', 'unit_price': 'inbound_buy:unit_price', + 'post_tax_unit_price': 'inbound_buy:post_tax_unit_price', 'tax_rate': 'inbound_buy:tax_rate', 'total_price': 'inbound_buy:total_price', 'currency': 'inbound_buy:currency', diff --git a/inventory-backend/app/models/inbound/buy.py b/inventory-backend/app/models/inbound/buy.py index 4e9cc2f..59a9534 100644 --- a/inventory-backend/app/models/inbound/buy.py +++ b/inventory-backend/app/models/inbound/buy.py @@ -34,6 +34,7 @@ class StockBuy(db.Model): # 财务与商务 unit_price = db.Column(db.Numeric(19, 4), default=0) # 现意为:不含税单价 + post_tax_unit_price = db.Column(db.Numeric(19, 4), default=0) # 税后单价 total_price = db.Column(db.Numeric(19, 4), default=0) # 总价 # [新增] 税率 tax_rate = db.Column(db.Numeric(5, 2), default=0) @@ -98,6 +99,7 @@ class StockBuy(db.Model): 'qty_available': float(self.available_quantity or 0), 'unit_price': float(self.unit_price or 0), + 'post_tax_unit_price': float(self.post_tax_unit_price or 0), 'total_price': float(self.total_price or 0), # [新增] 税率 'tax_rate': float(self.tax_rate or 0), @@ -116,4 +118,4 @@ class StockBuy(db.Model): 'global_print_id': self.global_print_id, 'global_print_id_str': f"{self.global_print_id:010d}" if self.global_print_id else "" - } \ No newline at end of file + } diff --git a/inventory-backend/app/services/inbound/buy_service.py b/inventory-backend/app/services/inbound/buy_service.py index 87532b3..219d691 100644 --- a/inventory-backend/app/services/inbound/buy_service.py +++ b/inventory-backend/app/services/inbound/buy_service.py @@ -138,6 +138,7 @@ class BuyInboundService: # 价格信息 unit_price=u_price, + post_tax_unit_price=float(data.get('post_tax_unit_price') or 0), tax_rate=tax_rate, # [新增] total_price=in_qty * u_price, currency=data.get('currency', 'CNY'), @@ -184,6 +185,8 @@ class BuyInboundService: # [新增] 更新税率 if 'tax_rate' in data: stock.tax_rate = float(data['tax_rate']) + # 更新税后单价 + if 'post_tax_unit_price' in data: stock.post_tax_unit_price = float(data['post_tax_unit_price']) if 'in_quantity' in data: diff = float(data['in_quantity']) - float(stock.in_quantity) @@ -322,4 +325,4 @@ class BuyInboundService: @staticmethod def get_history_locations(base_id): return [r[0] for r in - db.session.query(StockBuy.warehouse_location).filter(StockBuy.base_id == base_id).distinct().all()] \ No newline at end of file + db.session.query(StockBuy.warehouse_location).filter(StockBuy.base_id == base_id).distinct().all()] diff --git a/inventory-web/src/views/stock/inbound/buy.vue b/inventory-web/src/views/stock/inbound/buy.vue index 4111a7e..d0af1d9 100644 --- a/inventory-web/src/views/stock/inbound/buy.vue +++ b/inventory-web/src/views/stock/inbound/buy.vue @@ -1,7 +1,7 @@