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

📄 costcalculate.bas

📁 金算盘软件代码
💻 BAS
📖 第 1 页 / 共 2 页
字号:
Attribute VB_Name = "CostCalculate"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 成本计算
' 1998.7.13
' 作者:唐维勇
'
' 用途:本程序用于计算所有出库商品的出库成本(但不包括盘亏等)
'
' 计算公式:
'   1. 计划价
'       差异率=(期初差异+本期收入差异-收入退回差异)/(期初计划价+本期收入计划成本-收入退回计划成本)
'       出库差异=出库计划成本*差异率
'   2. 售价
'       差价率=期末分摊前商品进销差价÷(期末库存商品帐余额+本期销售成本)
'       入库进销差价=入库金额-销售成本(含税)*(1/(1+销项税率))
'       出库进销差价=销售成本(含税)*(1/(1+销项税率)) * 差价率
'       待实现销项税=销售成本(含税)*(销项税率/(1+销项税率))
'   3   全月(加权)平均
'       出库单价=(月初库存金额+本期收入金额)/(月初库存数量+本期收入数量)
'   4   移动平均
'       出库单价=结存金额/结存数量
'   5   先进先出
'   6   后进先出
'   7   批进批出
'   8   最后进价
'
' 个别计算底稿查询:
'   包括:“0+日期+进货明细ID: 所有进货明细
' 先进先出(后进先出)计算底稿查询:
'   包括:“0+日期+进货明细ID: 有对应出库的进货明细
'         “0+日期+出货明细ID: 有对应进库的出货明细
'         “1+日期+出货明细ID: 红子销售明细
'         “2”              : 成本调整明细
'         “3”              : 没有对应出库的进货明细
'
' 进退成本价却定方法:
'        先进先出 - 先进先出价
'        后进先出 - 后进先出价
'        全月平均 - 全月平均价
'        最后进价 - 最近进货价
'        个别价   - 指定进货价
'        移动平均 - 当前结存价
'        计划价   - 计划成本价
'        实际差价 - 售价成本价
' 出退成本价却定方法:
'        先进先出 - 最近进货价
'        后进先出 - 最近进货价
'        全月平均 - 期初结存价
'        最后进价 - 最近进货价
'        个别价   - 最近进货价
'        移动平均 - 当前结存价
'        计划价   - 计划成本价
'        实际差价 - 售价成本价
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit

'成本计算方法
Public Enum enumCostMethod
    cmMonthAvg = "1"                                           '全月平均
    cmMoveAvg = "2"                                            '移动平均
    cmFIFO = "3"                                               '先进先出
    cmLIFO = "4"                                               '后进先出
    cmSingle = "5"                                             '个别计价
    cmPlan = "6"                                               '计划成本
    cmRealDiff = "7"                                           '进销差价率
    cmLastPrice = "8"                                          '最后进价法
End Enum
        
'红字成本计算方法
Public Enum enumNegativeCostMethod
    ncmNoCost = "0"                                             '不计算成本
    ncmPlan = "1"                                               '计划成本
    ncmMoveAvg = "2"                                            '移动平均
    ncmLaterPrice = "3"                                         '最近进价
    ncmMaxPrice = "4"                                           '最高进价
    ncmMinPrice = "5"                                           '最低进价
    ncmAvgPrice = "6"                                           '平均进价
    ncmLastPrice = "7"                                          '上月结存价
    ncmLastDiffRate = "8"                                       '上月差价率(差异率)
    ncmLastQuarterDiffRate = "9"                                '上季差价率(差异率)
    ncmLastYearDiffRate = "10"                                  '上年差价率(差异率)
End Enum

Public Sub UpdateItemDaily2(lngItemID As Long, strDate As String, _
    lngActivityTypeID As Long, strCostMethod As String, _
    ByVal dblCost As Double, ByVal dblDiff As Double, ByVal dblSaleTax As Double, _
    strProduceNum As String, lngCustomID0 As Long, lngCustomID1 As Long, _
    lngCustomID2 As Long, lngCustomID3 As Long, lngCustomID4 As Long, lngCustomID5 As Long)
        
    Dim refUpdate As rdoQuery
    
    Set refUpdate = gclsBase.BaseDB.CreateQuery("", "{CALL " & gclsBase.UID & ".UpdateItemDaily2(?,?,?,?,?,?,?,?,?,?,?,?,?,?)}")
    refUpdate.rdoParameters(0).Type = rdTypeINTEGER
    refUpdate.rdoParameters(1).Type = rdTypeVARCHAR
    refUpdate.rdoParameters(2).Type = rdTypeINTEGER
    refUpdate.rdoParameters(3).Type = rdTypeVARCHAR
    refUpdate.rdoParameters(4).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(5).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(6).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(7).Type = rdTypeVARCHAR
    refUpdate.rdoParameters(8).Type = rdTypeINTEGER
    refUpdate.rdoParameters(9).Type = rdTypeINTEGER
    refUpdate.rdoParameters(10).Type = rdTypeINTEGER
    refUpdate.rdoParameters(11).Type = rdTypeINTEGER
    refUpdate.rdoParameters(12).Type = rdTypeINTEGER
    refUpdate.rdoParameters(13).Type = rdTypeINTEGER
    refUpdate.rdoParameters(0).Direction = rdParamInput
    refUpdate.rdoParameters(1).Direction = rdParamInput
    refUpdate.rdoParameters(2).Direction = rdParamInput
    refUpdate.rdoParameters(3).Direction = rdParamInput
    refUpdate.rdoParameters(4).Direction = rdParamInput
    refUpdate.rdoParameters(5).Direction = rdParamInput
    refUpdate.rdoParameters(6).Direction = rdParamInput
    refUpdate.rdoParameters(7).Direction = rdParamInput
    refUpdate.rdoParameters(8).Direction = rdParamInput
    refUpdate.rdoParameters(9).Direction = rdParamInput
    refUpdate.rdoParameters(10).Direction = rdParamInput
    refUpdate.rdoParameters(11).Direction = rdParamInput
    refUpdate.rdoParameters(12).Direction = rdParamInput
    refUpdate.rdoParameters(13).Direction = rdParamInput
    refUpdate.rdoParameters(0).Value = lngItemID
    refUpdate.rdoParameters(1).Value = strDate
    refUpdate.rdoParameters(2).Value = lngActivityTypeID
    refUpdate.rdoParameters(3).Value = strCostMethod
    refUpdate.rdoParameters(4).Value = dblCost
    refUpdate.rdoParameters(5).Value = dblDiff
    refUpdate.rdoParameters(6).Value = dblSaleTax
    refUpdate.rdoParameters(7).Value = Trim(strProduceNum)
    refUpdate.rdoParameters(8).Value = lngCustomID0
    refUpdate.rdoParameters(9).Value = lngCustomID1
    refUpdate.rdoParameters(10).Value = lngCustomID2
    refUpdate.rdoParameters(11).Value = lngCustomID3
    refUpdate.rdoParameters(12).Value = lngCustomID4
    refUpdate.rdoParameters(13).Value = lngCustomID5
    refUpdate.Execute
    refUpdate.Close
    Set refUpdate = Nothing
End Sub

Public Sub UpdateItemDaily1(lngItemID As Long, lngCustomerID As Long, strDate As String, _
    lngActivityTypeID As Long, strCostMethod As String, ByVal dblCost As Double, _
    ByVal dblDiff As Double, ByVal dblSaleTax As Double, dblQuantity As Double, dblAvgCost As Double, _
    strProduceNum As String, lngCustomID0 As Long, lngCustomID1 As Long, _
    lngCustomID2 As Long, lngCustomID3 As Long, lngCustomID4 As Long, lngCustomID5 As Long)
    
    Dim refUpdate As rdoQuery
    
    Set refUpdate = gclsBase.BaseDB.CreateQuery("", "{CALL " & gclsBase.UID & ".UpdateItemDaily2(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}")
    refUpdate.rdoParameters(0).Type = rdTypeINTEGER
    refUpdate.rdoParameters(1).Type = rdTypeINTEGER
    refUpdate.rdoParameters(2).Type = rdTypeVARCHAR
    refUpdate.rdoParameters(3).Type = rdTypeINTEGER
    refUpdate.rdoParameters(4).Type = rdTypeVARCHAR
    refUpdate.rdoParameters(5).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(6).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(7).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(8).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(9).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(10).Type = rdTypeVARCHAR
    refUpdate.rdoParameters(11).Type = rdTypeINTEGER
    refUpdate.rdoParameters(12).Type = rdTypeINTEGER
    refUpdate.rdoParameters(13).Type = rdTypeINTEGER
    refUpdate.rdoParameters(14).Type = rdTypeINTEGER
    refUpdate.rdoParameters(15).Type = rdTypeINTEGER
    refUpdate.rdoParameters(16).Type = rdTypeINTEGER
    refUpdate.rdoParameters(0).Direction = rdParamInput
    refUpdate.rdoParameters(1).Direction = rdParamInput
    refUpdate.rdoParameters(2).Direction = rdParamInput
    refUpdate.rdoParameters(3).Direction = rdParamInput
    refUpdate.rdoParameters(4).Direction = rdParamInput
    refUpdate.rdoParameters(5).Direction = rdParamInput
    refUpdate.rdoParameters(6).Direction = rdParamInput
    refUpdate.rdoParameters(7).Direction = rdParamInput
    refUpdate.rdoParameters(8).Direction = rdParamInput
    refUpdate.rdoParameters(9).Direction = rdParamInput
    refUpdate.rdoParameters(10).Direction = rdParamInput
    refUpdate.rdoParameters(11).Direction = rdParamInput
    refUpdate.rdoParameters(12).Direction = rdParamInput
    refUpdate.rdoParameters(13).Direction = rdParamInput
    refUpdate.rdoParameters(14).Direction = rdParamInput
    refUpdate.rdoParameters(15).Direction = rdParamInput
    refUpdate.rdoParameters(16).Direction = rdParamInput
    refUpdate.rdoParameters(0).Value = lngItemID
    refUpdate.rdoParameters(1).Value = lngCustomerID
    refUpdate.rdoParameters(2).Value = strDate
    refUpdate.rdoParameters(3).Value = lngActivityTypeID
    refUpdate.rdoParameters(4).Value = strCostMethod
    refUpdate.rdoParameters(5).Value = dblCost
    refUpdate.rdoParameters(6).Value = dblDiff
    refUpdate.rdoParameters(7).Value = dblSaleTax
    refUpdate.rdoParameters(8).Value = dblQuantity
    refUpdate.rdoParameters(9).Value = dblAvgCost
    refUpdate.rdoParameters(10).Value = Trim(strProduceNum)
    refUpdate.rdoParameters(11).Value = lngCustomID0
    refUpdate.rdoParameters(12).Value = lngCustomID1
    refUpdate.rdoParameters(13).Value = lngCustomID2
    refUpdate.rdoParameters(14).Value = lngCustomID3
    refUpdate.rdoParameters(15).Value = lngCustomID4
    refUpdate.rdoParameters(16).Value = lngCustomID5
    refUpdate.Execute
    refUpdate.Close
    Set refUpdate = Nothing
End Sub

Public Sub UpdatePositionDaily(lngItemID As Long, strDate As String, ByVal lngActivityTypeID As Long, _
    strCostMethod As String, ByVal dblAvgCost As Double, ByVal dblDiff As Double, ByVal dblSaleTax As Double, _
    lngPositionID As Long, strProduceNum As String, lngCustomID0 As Long, lngCustomID1 As Long, _
    lngCustomID2 As Long, lngCustomID3 As Long, lngCustomID4 As Long, lngCustomID5 As Long)

    Dim refUpdate As rdoQuery
    
    Set refUpdate = gclsBase.BaseDB.CreateQuery("", "{CALL " & gclsBase.UID & ".UpdateItemDaily2(?,?,?,?,?,?,?,?,?,?,?,?,?,?)}")
    refUpdate.rdoParameters(0).Type = rdTypeINTEGER
    refUpdate.rdoParameters(1).Type = rdTypeVARCHAR
    refUpdate.rdoParameters(2).Type = rdTypeINTEGER
    refUpdate.rdoParameters(3).Type = rdTypeVARCHAR
    refUpdate.rdoParameters(4).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(5).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(6).Type = rdTypeDOUBLE
    refUpdate.rdoParameters(7).Type = rdTypeVARCHAR
    refUpdate.rdoParameters(8).Type = rdTypeINTEGER
    refUpdate.rdoParameters(9).Type = rdTypeINTEGER
    refUpdate.rdoParameters(10).Type = rdTypeINTEGER
    refUpdate.rdoParameters(11).Type = rdTypeINTEGER
    refUpdate.rdoParameters(12).Type = rdTypeINTEGER
    refUpdate.rdoParameters(13).Type = rdTypeINTEGER
    refUpdate.rdoParameters(0).Direction = rdParamInput
    refUpdate.rdoParameters(1).Direction = rdParamInput
    refUpdate.rdoParameters(2).Direction = rdParamInput
    refUpdate.rdoParameters(3).Direction = rdParamInput
    refUpdate.rdoParameters(4).Direction = rdParamInput
    refUpdate.rdoParameters(5).Direction = rdParamInput
    refUpdate.rdoParameters(6).Direction = rdParamInput
    refUpdate.rdoParameters(7).Direction = rdParamInput
    refUpdate.rdoParameters(8).Direction = rdParamInput
    refUpdate.rdoParameters(9).Direction = rdParamInput
    refUpdate.rdoParameters(10).Direction = rdParamInput
    refUpdate.rdoParameters(11).Direction = rdParamInput
    refUpdate.rdoParameters(12).Direction = rdParamInput
    refUpdate.rdoParameters(13).Direction = rdParamInput
    refUpdate.rdoParameters(0).Value = lngItemID
    refUpdate.rdoParameters(1).Value = strDate
    refUpdate.rdoParameters(2).Value = lngActivityTypeID
    refUpdate.rdoParameters(3).Value = strCostMethod
    refUpdate.rdoParameters(4).Value = dblAvgCost
    refUpdate.rdoParameters(5).Value = dblDiff
    refUpdate.rdoParameters(6).Value = dblSaleTax

⌨️ 快捷键说明

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