BOS单据分录增加即时库存的解决方案Demo
因为库存是可以从多维度进行计算库存的,所以即使库存一般是采用插件方式实现,根据自己需求传入不同的参数来获取对应的库存。
1.在分录中添加一个数量类型字段(设计时可以参考组装单或拆卸单的即时库存字段),然后在单据插件中实现m_BillInterface_Change接口。
'------------------------------------------------------------------
' 函数名称 : 值更新事件
' 描述 :刷新指定行的库存
' 创建时间 :2020-03-10
'------------------------------------------------------------------
Private Sub m_BillInterface_Change(ByVal dct As KFO.Dictionary, ByVal dctFld As KFO.Dictionary, ByVal Col As Long, ByVal Row As Long, Cancel As Boolean)
Select Case dct("FKey")
Case "FStockID", "FSPID", "FBatchNo", "FUnitID", "FKFDate", "FKFPeriod", "FPeriodDate"
'当为仓库、仓位、批号、单位、辅助属性、采购日期、保质期、截至日期等属性改变时,刷新即时库存
RefreshStockQty Row
End Select
End Sub
'------------------------------------------------------------------
' 函数名称 : GetStockQty
' 描述 :刷新指定行的库存
' 创建时间 :2020-03-10
'------------------------------------------------------------------
Private Sub RefreshStockQty(ByVal lRow As Long)
Dim lItemID As String
Dim lUnitID As Long
Dim dicParas As KFO.Dictionary
Dim obj As Object
Dim dStockQty As Double
Dim sStockQty As String
Dim lQtyDecimal As Long
Dim lIndex As Long
Dim strKey As String
Dim dct As KFO.Dictionary
If Inside(m_BillInterface.DataSrv.ClassTypeID, 1007000, 1007451) Then
lItemID = Val(m_BillInterface.GetFieldValue("FItemID", lRow, Enu_ValueType_FFLD))
If lItemID > 0 Then
lUnitID = Val(m_BillInterface.GetFieldValue("FUnitID", lRow, Enu_ValueType_FFLD))
'Enu_ValueType_FFLD 0 保存到数据库中的值。
'Enu_ValueType_FFND 1 查找类型字段的内码值。
'Enu_ValueType_FDSP 2 显示在界面上的值。
Set dicParas = New KFO.Dictionary
dicParas("FStockID") = m_BillInterface.GetFieldValue("FStockID", lRow, Enu_ValueType_FFLD)
dicParas("FSPID") = m_BillInterface.GetFieldValue("FSPID", lRow, Enu_ValueType_FFLD)
dicParas("FBatchNo") = m_BillInterface.GetFieldValue("FBatchNo", lRow, Enu_ValueType_FFLD)
dicParas("AuxPropID") = Val(m_BillInterface.GetFieldValue("FAuxPropID", lRow, Enu_ValueType_FFLD))
dicParas("FKFDate") = m_BillInterface.GetFieldValue("FKFDate", lRow, Enu_ValueType_FFLD)
dicParas("FKFPeriod") = m_BillInterface.GetFieldValue("FKFPeriod", lRow, Enu_ValueType_FFLD)
'获取库存数量(不需要过滤的参数:数值类型设置为0,字符串类型设置为空。即可)
Set obj = CreateObject("BillDataAccess.SysInfo")
dStockQty = obj.GetStockQty(MMTS.PropsString, lItemID, lUnitID, dicParas)
lQtyDecimal = dicParas.GetValue("FQtyDecimal", 4)
'将值设置到单元格中去
m_BillInterface.SetFieldValue "FQty1", dStockQty, lRow
'设置精度
Set dct = m_BillInterface.GetFieldInfoByKey("FQty1", strKey, lIndex)
m_BillInterface.SetDecimal dct, lRow, lQtyDecimal
End If
End If
End Sub
BOS单据分录增加即时库存的解决方案Demo
本文2024-09-22 16:40:01发表“k3wise知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3wise-89410.html