⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bos_loanlist_plugins.cls

📁 完成报销系统的业务流程;在报销系统中达到预算控制目的;将历史数据导入金蝶账套生成历史备查数据。
💻 CLS
📖 第 1 页 / 共 2 页
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "BOS_LoanList_PlugIns"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Attribute VB_Description = "This is ListEvents Interface Class, made by K3BOSPLUGINSWIZAED"
Option Explicit

 
'定义 ListEvents 接口. 必须具有的声明, 以此来获得事件
Private WithEvents m_ListInterface  As ListEvents
Attribute m_ListInterface.VB_VarHelpID = -1
Public mnuBack As KFO.Dictionary
 
Public Sub Show(ByVal oListInterface As Object)

    'ListEvents 接口实现
    '注意: 此方法必须存在, 请勿修改
    Set m_ListInterface = oListInterface

End Sub

Private Sub Class_Terminate()

    '释放接口对象
    '注意: 此方法必须存在, 请勿修改
    Set m_ListInterface = Nothing

End Sub

Private Sub m_ListInterface_MenuBarClick(ByVal BOSTool As K3ClassEvents.BOSTool, Cancel As Boolean)
            Dim Vch As Object, Mode As Long
            Dim VchId As Long
    Dim bret As Boolean

        Select Case BOSTool.ToolName
        Case "CreVou"

            bret = ImportLoanVou(m_ListInterface.GetSelectedBillInfo)
        Case "makeVou"
            VchId = getVouid(m_ListInterface.GetSelectedBillInfo)
            If VchId = 0 Then
                bret = ImportLoanVou(m_ListInterface.GetSelectedBillInfo)
            Else
                 '弹出凭证界面修改凭证
                VchId = getVouid(m_ListInterface.GetSelectedBillInfo)
                If VchId <> 0 Then
                    Set Vch = CreateObject("Mvedit.MVoucherEdit")
                    Mode = 2
                    Vch.LoadVoucher Mode, VchId
                    AlterVouNo VchId
                End If
                Set Vch = Nothing
            End If
        Case "viewVou"
        Case "mnuEditDelete"
           If VerUser(m_ListInterface.GetSelectedBillInfo) = False Then
                Cancel = True
           End If
        Case Else
        End Select

End Sub
'***********************************************************************************
'导入凭证
'参数 VouVector 用户选择的借款单据信息
'
'***********************************************************************************
Private Function ImportLoanVou(VouVector As KFO.Vector) As Boolean
    Dim glVouRs As New KFO.Vector
    Dim lFid As Long                            '单据编号
    Dim glvch As Object                         '中间层凭证对象
    Dim mvch As KFO.Dictionary                  '待保存凭证头
    Dim mvchentry As KFO.Vector                 '待保存凭证分录集
    Dim entry As KFO.Dictionary                 '待保存凭证分录
    Dim mvchdetail As KFO.Vector                '核算项目明细集
    Dim detail As KFO.Dictionary                '核算项目明细
    Dim i, iCount As Long, j As Long
    Dim vValue      As Variant
    Dim rs As New ADODB.Recordset
    
    Dim sVouType() As String  '凭证模板数组
    
    Dim sDepId As String         '部门编码
    Dim sProposer As String      '申请人编码
    Dim lLoanItem As Long       '借款项目
    Dim lLoanType As Long       '借款方式
    Dim sBillNo As String       '单据编码
    Dim sSql As String
    Dim sInfo As String          '最后提示信息
    Dim sfid As String          '要更新单据内码集
    Dim bret As Boolean

    Dim tmpRs As New ADODB.Recordset
    On Error GoTo ERR
    sInfo = ""
    '此处添加处理 生成凭头
    Set mvch = New KFO.Dictionary
    Dim sYear As String
    Dim sPeriod As String
    sYear = m_ListInterface.K3Lib.GetData("select FValue from t_systemprofile where FCategory='GL' and FKey='CurrentYear'")("FValue")
    sPeriod = m_ListInterface.K3Lib.GetData("select FValue from t_systemprofile where FCategory='GL' and FKey='CurrentPeriod'")("FValue")
    mvch("FDate") = getDate(sYear, sPeriod)
'    mvch("FDate") = m_ListInterface.K3Lib.GetData("SELECT GETDATE() AS FDate")("Fdate")
    mvch("FGroupID") = "1"
'    mvch("FReference") =
    
    Set mvchentry = New KFO.Vector
    '取凭证分录模板
     bret = getVouEntryInfo(sVouType())
     If bret = False Then
        MsgBox "请设置借款申请单的凭证模板!"
        ImportLoanVou = False
        Exit Function
     End If
    
    With VouVector
    i = 1
begFor: While i <= VouVector.Size
            '取单据编号
            lFid = .Item(i)("Fid")
            '取单据信息
            sSql = "select t2.Fnumber as DepNum,t3.Fnumber as ProposerNum,* from t_EP_ER_Loan t1" & _
                    " left join t_item t2 on t2.Fitemclassid=2 and  t1.FReqDept =t2.Fitemid " & _
                    "left join t_item t3 on t3.Fitemclassid=3 and  t1.FProposer =t3.Fitemid where t1.Fid='" & lFid & "'"
                    
            Set rs = m_ListInterface.K3Lib.GetData(sSql)
            If rs.State = adStateOpen And rs.RecordCount = 1 Then
                '判断是否生成过凭证 '判断是否已经审核
                If Not (CStr(rs("FVouUser")) = "" Or CLng(rs("FVouUser") = 0)) <> 0 Then
                    sSql = "select isnull(count(*),0)  as vouCun from t_voucher where fvoucherid= '" & rs!FVouid & "'"
                    Set tmpRs = m_ListInterface.K3Lib.GetData(sSql)
                    If tmpRs!vouCun <> 0 Then
                        i = i + 1
                        sInfo = sInfo & "借款申请单:" & rs("FBillno") & "生成凭证失败!原因:已经生成凭证" & vbCrLf
                        GoTo begFor
                    End If
                    Set tmpRs = Nothing
                End If

                If CLng(rs("FUser")) = 0 Then
                     i = i + 1
                     sInfo = sInfo & "借款申请单:" & rs("FBillno") & "生成凭证失败!原因: 单据还没有审核。" & vbCrLf
                     GoTo begFor
                End If

            End If
  
                '部门 ,申请人,金额,借款项目
                sDepId = rs("DepNum")
                sProposer = rs("ProposerNum")
                vValue = rs("FCtlAmt")
                lLoanItem = rs("FLoanItem")
                lLoanType = rs("FLoanType")
                sBillNo = rs("FBillno")

                '创建凭证分录
                Set entry = New KFO.Dictionary
                
                If lLoanType = 1000203 Then lLoanType = 1000202
                
                For j = 1 To UBound(sVouType, 2)
                    If sVouType(1, j) = lLoanType Then '借款方式相同
                        Set entry = New KFO.Dictionary
                        entry("FExplanation") = "借款申请单,单据编号:" & sBillNo & vbCrLf & "借款用途:" & CNulls(rs("FNote1"), "")
                        entry("FAccountID") = sVouType(3, j)
                        entry("FDC") = sVouType(2, j)
                        entry("FAmount") = vValue
                        entry("FQuantity") = 0
                        entry("FUnitPrice") = 0
                        entry("FMeasureUnitID") = 0
                                            
                        Set mvchdetail = New KFO.Vector
                        '创建核算项目明细
                        If sVouType(4, j) <> "" Then
                            
                            Set detail = New KFO.Dictionary
                            detail("FItemClassNumber") = sVouType(4, j)
                            If sVouType(4, j) = "002" Then detail("FItemNumber") = sDepId
                            If sVouType(4, j) = "003" Then detail("FItemNumber") = sProposer
                            mvchdetail.Add detail
                        End If
                        If sVouType(5, j) <> "" Then
'                            Set mvchdetail = New KFO.Vector
                            Set detail = New KFO.Dictionary
                            detail("FItemClassNumber") = sVouType(5, j)
                            If sVouType(5, j) = "002" Then detail("FItemNumber") = sDepId
                            If sVouType(5, j) = "003" Then detail("FItemNumber") = sProposer
                            mvchdetail.Add detail
                            
                        End If
                       Set entry("_Details") = mvchdetail
                        mvchentry.Add entry
                       
                    End If
                Next j
                '拼生凭证正确的单据内码
                If entry.Count <> 0 Then
                    If sfid = "" Then
                        sfid = sfid & CStr(lFid)
                    Else
                        sfid = sfid & "," & CStr(lFid)
                    End If
                    sInfo = sInfo & "借款申请单:" & rs("FBillno") & "生成凭证成功!" & vbCrLf
                Else
                    sInfo = sInfo & "借款申请单:" & rs("FBillno") & "生成凭证失败!原因:该借款方式的凭证模板设置错误!" & vbCrLf
                End If
            
            If rs.State = adStateOpen Then rs.Close
            i = i + 1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -