feat: add post-tax unit price, company filter, and frontend price linkage

Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
dxc
2026-02-27 15:58:55 +08:00
parent 3c1c822f88
commit 657c916703
4 changed files with 20 additions and 8 deletions

View File

@ -119,12 +119,13 @@ def get_list():
# 新增筛选参数 # 新增筛选参数
category = request.args.get('category', '') category = request.args.get('category', '')
material_type = request.args.get('material_type', '') material_type = request.args.get('material_type', '')
company = request.args.get('company', '')
# 状态参数处理 # 状态参数处理
statuses_str = request.args.get('statuses', '') statuses_str = request.args.get('statuses', '')
statuses = statuses_str.split(',') if statuses_str else [] statuses = statuses_str.split(',') if statuses_str else []
result = BuyInboundService.get_list(page, limit, keyword, statuses, category, material_type) result = BuyInboundService.get_list(page, limit, keyword, statuses, category, material_type, company)
# 字段级脱敏 # 字段级脱敏
user_permissions = get_current_user_permissions() user_permissions = get_current_user_permissions()
if result.get('items'): if result.get('items'):

View File

@ -33,7 +33,7 @@ class StockBuy(db.Model):
available_quantity = db.Column(db.Numeric(19, 4), default=0) available_quantity = db.Column(db.Numeric(19, 4), default=0)
# 财务与商务 # 财务与商务
unit_price = db.Column(db.Numeric(19, 4), default=0) # 现意为:不含税单价 pre_tax_unit_price = db.Column(db.Numeric(19, 4), default=0) # 现意为:不含税单价
post_tax_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) # 总价 total_price = db.Column(db.Numeric(19, 4), default=0) # 总价
# [新增] 税率 # [新增] 税率
@ -98,7 +98,7 @@ class StockBuy(db.Model):
'available_quantity': float(self.available_quantity or 0), 'available_quantity': float(self.available_quantity or 0),
'qty_available': float(self.available_quantity or 0), 'qty_available': float(self.available_quantity or 0),
'unit_price': float(self.unit_price or 0), 'unit_price': float(self.pre_tax_unit_price or 0),
'post_tax_unit_price': float(self.post_tax_unit_price or 0), 'post_tax_unit_price': float(self.post_tax_unit_price or 0),
'total_price': float(self.total_price or 0), 'total_price': float(self.total_price or 0),
# [新增] 税率 # [新增] 税率

View File

@ -137,7 +137,7 @@ class BuyInboundService:
warehouse_location=data.get('warehouse_location'), warehouse_location=data.get('warehouse_location'),
# 价格信息 # 价格信息
unit_price=u_price, pre_tax_unit_price=u_price,
post_tax_unit_price=float(data.get('post_tax_unit_price') or 0), post_tax_unit_price=float(data.get('post_tax_unit_price') or 0),
tax_rate=tax_rate, # [新增] tax_rate=tax_rate, # [新增]
total_price=in_qty * u_price, total_price=in_qty * u_price,
@ -195,9 +195,9 @@ class BuyInboundService:
stock.stock_quantity = float(stock.stock_quantity) + diff stock.stock_quantity = float(stock.stock_quantity) + diff
stock.available_quantity = float(stock.available_quantity) + diff stock.available_quantity = float(stock.available_quantity) + diff
if 'unit_price' in data: stock.unit_price = float(data['unit_price']) if 'unit_price' in data: stock.pre_tax_unit_price = float(data['unit_price'])
stock.total_price = float(stock.in_quantity) * float(stock.unit_price) stock.total_price = float(stock.in_quantity) * float(stock.pre_tax_unit_price)
db.session.commit() db.session.commit()
return stock return stock
except Exception as e: except Exception as e:

View File

@ -55,7 +55,7 @@
<el-button class="reset-btn" @click="resetQuery">重置</el-button> <el-button class="reset-btn" @click="resetQuery">重置</el-button>
</div> </div>
<div class="right-actions"> <div class="right-actions" style="flex-wrap: wrap;">
<el-button v-if="userStore.hasPermission('inbound_buy:operation')" type="primary" :icon="Plus" @click="handleCreate" class="add-btn">新增</el-button> <el-button v-if="userStore.hasPermission('inbound_buy:operation')" type="primary" :icon="Plus" @click="handleCreate" class="add-btn">新增</el-button>
<el-button :icon="Refresh" circle @click="fetchData" class="circle-btn" /> <el-button :icon="Refresh" circle @click="fetchData" class="circle-btn" />
@ -296,7 +296,6 @@
<el-col :span="6"> <el-col :span="6">
<el-form-item label="入库日期" prop="in_date"><el-date-picker v-model="form.in_date" type="date" value-format="YYYY-MM-DD" style="width:100%" disabled/></el-form-item> <el-form-item label="入库日期" prop="in_date"><el-date-picker v-model="form.in_date" type="date" value-format="YYYY-MM-DD" style="width:100%" disabled/></el-form-item>
</el-col> </el-col>
<!-- 条形码输入框已隐藏 -->
<el-col :span="6"> <el-col :span="6">
<el-form-item label="库位" prop="warehouse_location"> <el-form-item label="库位" prop="warehouse_location">
<el-autocomplete <el-autocomplete
@ -1058,6 +1057,18 @@ watch(() => [form.in_quantity, form.unit_price], () => {
form.post_tax_unit_price = Number((form.unit_price * taxMultiplier).toFixed(4)); form.post_tax_unit_price = Number((form.unit_price * taxMultiplier).toFixed(4));
}) })
const updatePrices = (source) => {
const taxMultiplier = 1 + (form.tax_rate || 0) / 100;
if (source === 'pre') {
form.post_tax_unit_price = Number((form.unit_price * taxMultiplier).toFixed(4));
} else if (source === 'post') {
form.unit_price = Number((form.post_tax_unit_price / taxMultiplier).toFixed(4));
} else if (source === 'tax') {
form.post_tax_unit_price = Number((form.unit_price * taxMultiplier).toFixed(4));
}
form.total_price = Number((form.in_quantity * form.unit_price).toFixed(4));
}
const fetchData = async () => { const fetchData = async () => {
loading.value = true loading.value = true
try { try {