提交 85084238 authored 作者: 李思鑫's avatar 李思鑫

feat:一个采购订单多次入库

上级 e309cb96
...@@ -100,16 +100,26 @@ def edit_Storehouse(request,id=None): ...@@ -100,16 +100,26 @@ def edit_Storehouse(request,id=None):
#lisin 2024-08-24 包材管理相关 #lisin 2024-08-24 包材管理相关
#采购记录查询 #采购记录查询
@login_required
def packaging_purchase_query(request): def packaging_purchase_query(request):
packaging_purchase_id = request.GET.get('id') packaging_purchase_id = request.GET.get('id')
try: try:
packaging_purchase = PackagingPurchasRecord.objects.get(id=packaging_purchase_id) packaging_purchase = PackagingPurchasRecord.objects.get(id=packaging_purchase_id)
print('packaging_purchase.packaging--',packaging_purchase.packaging.id)
packaging = Packaging.objects.get(id=packaging_purchase.packaging.id) packaging = Packaging.objects.get(id=packaging_purchase.packaging.id)
vendor = Vendor.objects.get(id=packaging_purchase.vendor.id) vendor = Vendor.objects.get(id=packaging_purchase.vendor.id)
# 已入库数量查询
packaging_instore = PackagingInstore.objects.filter(company=request.user.company, packaging_purchas=packaging_purchase)
print('packaging_inventory',packaging_instore)
yet_instore_num = 0
if len(packaging_instore):
for i in packaging_instore:
yet_instore_num += i.instore_num
data = { data = {
'dt': packaging_purchase.dt, 'dt': packaging_purchase.dt,
'qty': packaging_purchase.qty, 'qty': packaging_purchase.qty, #采购数量
'yet_instore_num': yet_instore_num, #已入库数量
'packaging_id': packaging.id, 'packaging_id': packaging.id,
'packaging_code': packaging.code, 'packaging_code': packaging.code,
'packaging_name': packaging.name, 'packaging_name': packaging.name,
...@@ -254,7 +264,7 @@ def packaging_inventory(request,what=None): ...@@ -254,7 +264,7 @@ def packaging_inventory(request,what=None):
data['clmns']=[_("包材编码"),_("包材名称"),_("规格型号"),_("单位"),_("采购数量"),_("入库数量"),_("领用数量"),_("库存数量")] data['clmns']=[_("包材编码"),_("包材名称"),_("规格型号"),_("单位"),_("采购数量"),_("入库数量"),_("领用数量"),_("库存数量")]
s="select a.id, coalesce(p.code,''), coalesce(p.name,''), coalesce(p.specification,'/'),"+\ s="select a.id, coalesce(p.code,''), coalesce(p.name,''), coalesce(p.specification,'/'),"+\
"case when p.unit_id IS NOT NULL THEN (select name from mes_unit where id=p.unit_id) else '/' end,"+\ "case when p.unit_id IS NOT NULL THEN (select name from mes_unit where id=p.unit_id) else '/' end,"+\
"SUM(purchase.qty), SUM(instore.instore_num), SUM(receive.receive_num), a.num "+\ "SUM(distinct purchase.qty), SUM(distinct instore.instore_num), SUM(distinct receive.receive_num), a.num "+\
"from mes_packaginginventory a "+\ "from mes_packaginginventory a "+\
"inner join mes_packaging p on a.packaging_id=p.id "+\ "inner join mes_packaging p on a.packaging_id=p.id "+\
"inner join mes_packagingpurchasrecord purchase on purchase.packaging_id=p.id "+\ "inner join mes_packagingpurchasrecord purchase on purchase.packaging_id=p.id "+\
......
...@@ -49,9 +49,12 @@ ...@@ -49,9 +49,12 @@
$('#id_instore_num').on('input', function(){ $('#id_instore_num').on('input', function(){
var purchase_num= $('#qty').val()*1; var purchase_num= $('#qty').val()*1;
var instore_num = $(this).val()*1; var instore_num = $(this).val()*1;
var yet_instore_num = $('#yet_instore_num').val()*1;
var can_instore_num = purchase_num - yet_instore_num;//可入库数量
console.log(can_instore_num, yet_instore_num)
if(purchase_num && instore_num){ if(purchase_num && instore_num){
if(instore_num > purchase_num){ if(instore_num > can_instore_num){
toastr.error('入库数量不能大于采购数量'); toastr.error('入库数量不能大于' + can_instore_num);
$('#id_instore_num').val(''); $('#id_instore_num').val('');
} }
} }
...@@ -72,7 +75,7 @@ ...@@ -72,7 +75,7 @@
console.log('packagingPurchasRecord',response) console.log('packagingPurchasRecord',response)
const { const {
dt, dt,
qty, qty, yet_instore_num,
packaging_id,packaging_code, packaging_name, packaging_specification, packaging_id,packaging_code, packaging_name, packaging_specification,
vendor_name vendor_name
}=response }=response
...@@ -83,6 +86,7 @@ ...@@ -83,6 +86,7 @@
$('#packaging_specification').val(packaging_specification); $('#packaging_specification').val(packaging_specification);
$('#vendor_name').val(vendor_name); $('#vendor_name').val(vendor_name);
$('#qty').val(qty); $('#qty').val(qty);
$('#yet_instore_num').val(yet_instore_num);
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
console.error('AJAX请求失败:', error); console.error('AJAX请求失败:', error);
...@@ -142,6 +146,12 @@ ...@@ -142,6 +146,12 @@
<input type="text" disabled name='qty' id='qty' /> <input type="text" disabled name='qty' id='qty' />
</div> </div>
</div> </div>
<div class="form-group ">
<label class="col-sm-2 control-label ">{% trans '已入库数量:' %} </label>
<div class="col-sm-10">
<input type="text" disabled name='yet_instore_num' id='yet_instore_num' />
</div>
</div>
<div class="form-group "> <div class="form-group ">
<label class="col-sm-2 control-label ">{% trans '入库数量:' %} </label> <label class="col-sm-2 control-label ">{% trans '入库数量:' %} </label>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论