?? bos_wipe3list_plugins.cls
字號:
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_Wipe3List_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"
'定義 ListEvents 接口. 必須具有的聲明, 以此來獲得事件
Private WithEvents m_ListInterface As ListEvents
Attribute m_ListInterface.VB_VarHelpID = -1
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 bret As Boolean
Dim Vch As Object, Mode As Long
Dim VchId As Long
Select Case BOSTool.ToolName
Case "makeVou"
VchId = getVouid(m_ListInterface.GetSelectedBillInfo)
If VchId = 0 Then
bret = ImportWipeVou_new(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 "mnuEditDelete"
If VerUser(m_ListInterface.GetSelectedBillInfo) = False Then
Cancel = True
End If
Case Else
End Select
End Sub
'***********************************************************************************
'導入憑證
'參數 VouVector 用戶選擇的報銷單據信息
'
'***********************************************************************************
Private Function ImportWipeVou(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, k 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 lWipeItem As Long '報銷項目
Dim lLoanType As Long '借款方式
Dim sBillNo As String '單據編碼
Dim cWipeAmt As Currency '報銷金額
Dim cLoanamt As Currency '借款金額
Dim lfidSRC As Long '源單內碼
Dim iVouTplType As Integer '憑證模板類型
Dim sSql As String
Dim sInfo As String '最后提示信息
Dim sfid As String '要更新單據內碼集
Dim tmpmvchentry As KFO.Vector '臨時保存一張單據中的分錄集
Dim bret As Boolean
Dim sErr As String
Dim tmpRs As 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
'***********************************************
With VouVector
i = 1
begFor: While i <= VouVector.Size
'取單據編號
lFid = .Item(i)("Fid")
'判斷是否生成過憑證, '判斷是否已經審核
sSql = "select FVouUser,FVouid,FBillno,FUser from t_EP_ER_WipeOff3 t1 where t1.Fid='" & lFid & "'"
Set rs = m_ListInterface.K3Lib.GetData(sSql)
If rs.State = adStateOpen And rs.RecordCount > 0 Then
sInfo = sInfo & "差旅費報銷單:" & rs("FBillno") & "生成憑證"
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 & "失??!原因: 已經生成憑證。" & vbCrLf
GoTo begFor
End If
If tmpRs.State = adStateOpen Then tmpRs.Close
End If
If CLng(rs("FUser")) = 0 Then
i = i + 1
sInfo = sInfo & "失敗!原因: 單據還沒有審核。" & vbCrLf
GoTo begFor
End If
End If
If rs.State = adStateOpen Then rs.Close
'
'取單據信息
sSql = "select t2.Fnumber as DepNum,t3.Fnumber as ProposerNum,* from t_EP_ER_WipeOff3Entry3 t1" & _
" Inner join t_EP_ER_WipeOff3 t11 on t1.fid=t11.fid " & _
" left join t_item t2 on t2.Fitemclassid=2 and t1.FDivideDep =t2.Fitemid " & _
" left join t_item t3 on t3.Fitemclassid=3 and t11.FProposer =t3.Fitemid " & _
" where t1.Fid='" & lFid & "'"
Set rs = m_ListInterface.K3Lib.GetData(sSql)
'單據存在繼續
If rs.State = adStateOpen And rs.RecordCount > 0 Then
'初始化一張單據的憑證分錄集********************************
Set tmpmvchentry = New KFO.Vector
'**********************************************************
k = 1
begwhile: While k <= rs.RecordCount
'部門 ,申請人,報銷項目,借款方式,單據編號,報銷金額,借款金額,源單內碼
sDepId = rs("DepNum")
sProposer = rs("ProposerNum")
lWipeItem = rs("FWipeItem")
lLoanType = rs("FLoanType")
sBillNo = rs("FBillno")
cWipeAmt = rs("FWipeAmt")
cLoanamt = rs("FLoanAmt")
lfidSRC = rs("FID_SRC")
'判斷報銷單的類型
' 1有借款單,且是現金'
' 2有借款單,且是銀行存款'
' 3沒有借款單,直接借款報銷'
If lfidSRC <> 0 And lLoanType = "1000201" Then
iVouTplType = 1
ElseIf lfidSRC <> 0 And lLoanType = "1000202" Then
iVouTplType = 2
ElseIf lfidSRC = 0 Then
iVouTplType = 3
Else
k = k + 1
sInfo = sInfo & "差旅費報銷單:" & rs("FBillno") & "中的第" & k & "第分錄,不能生成憑證!原因:報銷單不在5種報銷類型中" & vbCrLf
GoTo begwhile
End If
'取憑證分錄模板
bret = getVouEntryInfo(rs("FDivideDep"), lWipeItem, iVouTplType, sVouType())
If bret = False Then
k = k + 1
sInfo = sInfo & "差旅費報銷單:" & rs("FBillno") & "中的第" & k & "第分錄,不能生成憑證!原因:沒有對應的憑證模板" & vbCrLf
GoTo begwhile
Exit Function
End If
' 4有借款單,其預借的金額不夠。'
' 5有借款單,且有剩于金額"
If lfidSRC <> 0 And cWipeAmt > cLoanamt Then
iVouTplType = 4
ElseIf lfidSRC <> 0 And cWipeAmt < cLoanamt Then
iVouTplType = 5
End If
'創建憑證分錄
Set entry = New KFO.Dictionary
For j = 1 To UBound(sVouType, 2)
Set entry = New KFO.Dictionary
entry("FExplanation") = "差旅費報銷單,單據編號:" & sBillNo
entry("FAccountID") = sVouType(3, j)
entry("FDC") = sVouType(2, j)
'有借款單,其預借的金額不夠 貸方多加一個現金分錄
If iVouTplType = 4 And sVouType(2, j) = 0 Then
entry("FAmount") = cLoanamt
ElseIf iVouTplType = 4 And sVouType(2, j) = 1 Then
entry("FAmount") = cWipeAmt
'5有借款單,且有剩于金額" 借方多加一個現金分錄
ElseIf iVouTplType = 5 And sVouType(2, j) = 1 Then
entry("FAmount") = cWipeAmt
ElseIf iVouTplType = 5 And sVouType(2, j) = 0 Then
entry("FAmount") = cLoanamt
Else
entry("FAmount") = cWipeAmt
End If
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
tmpmvchentry.Add entry
' mvchentry.Add entry
Next j
'有借款單,其預借的金額不夠 貸方多加一個現金分錄
If iVouTplType = 4 Then
Set entry = New KFO.Dictionary
entry("FExplanation") = "差旅費報銷單,單據編號:" & sBillNo
entry("FAccountID") = "1000"
entry("FDC") = 0
entry("FAmount") = cWipeAmt - cLoanamt
entry("FQuantity") = 0
entry("FUnitPrice") = 0
entry("FMeasureUnitID") = 0
Set mvchdetail = New KFO.Vector
Set entry("_Details") = mvchdetail
tmpmvchentry.Add entry
' mvchentry.Add entry
End If
'5有借款單,且有剩于金額" 借方多加一個現金分錄
If iVouTplType = 5 Then
Set entry = New KFO.Dictionary
entry("FExplanation") = "差旅費報銷單,單據編號:" & sBillNo
entry("FAccountID") = 1000
entry("FDC") = 1
entry("FAmount") = cLoanamt - cWipeAmt
entry("FQuantity") = 0
entry("FUnitPrice") = 0
entry("FMeasureUnitID") = 0
Set mvchdetail = New KFO.Vector
Set entry("_Details") = mvchdetail
tmpmvchentry.Add entry
' mvchentry.Add entry
End If
k = k + 1
rs.MoveNext
Wend
'拼生憑證正確的單據內碼
If tmpmvchentry.Size > 0 Then
For j = 1 To tmpmvchentry.Size
mvchentry.Add tmpmvchentry.Item(j)
Next j
If sfid = "" Then
sfid = sfid & CStr(lFid)
Else
sfid = sfid & "," & CStr(lFid)
End If
sInfo = sInfo & "差旅費報銷單:" & sBillNo & "生成憑證成功!" & vbCrLf
Else
sInfo = sInfo & "差旅費報銷單:" & sBillNo & "生成憑證失敗!原因如上" & ERR.Description & vbCrLf
End If
End If
If rs.State = adStateOpen Then rs.Close
i = i + 1
Wend
Set mvch("_Entries") = mvchentry
End With
Dim s As String
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -