最近碰到了销售订单中,字段间信息计算的问题,
问题描述:
销售订单中,产品的目录单价、数量为人工进行填写,但是业务流程中,价格填写模式为:销售合同回来-目录价格-下浮比-实际价格
销售订单的实际价格为锁定模式,不能人为进行编辑,故导致了合同录入人员在录入过程中需要人工计算下浮比且小数点后位数控制困难;
解决方案:
1.在数据库中将【实际单价】字段解锁;
update ictemplateentry set FEnable=48 where FHeadCaption=‘实际含税单价‘ and FCtlOrder=27 and FCtlIndex=18
--ictemplateentry 表示老单中所有表中分录体中的字段信息,FEnable控制字段的输入模式及类型(0-表示锁定,48表示可以输入)
2.开发插件,根据老单插件说明进行开发,主要涉及到字段间关联的信息及列总和的更新;代码如下
‘定义插件对象接口. 必须具有的声明, 以此来获得事件 Private WithEvents m_BillTransfer As k3BillTransfer.Bill Public Sub Show(ByVal oBillTransfer As Object) ‘接口实现 ‘注意: 此方法必须存在, 请勿修改 Set m_BillTransfer = oBillTransfer End Sub Private Sub Class_Terminate() ‘释放接口对象 ‘注意: 此方法必须存在, 请勿修改 Set m_BillTransfer = Nothing End Sub Private Sub m_BillTransfer_GridChange(ByVal Col As Long, ByVal Row As Long, ByVal Value As Variant, ByVal bNewBill As Boolean, Cancel As Boolean) ‘TODO: 请在此处添加代码响应事件 GridChange Dim Colu As Integer ‘‘27 ‘‘Colu = 27 ‘‘实际含税单价 Dim FColu As Integer ‘‘21 ‘‘FColu = 21 ‘‘ 含税单价 Dim TaxCol As Integer ‘‘24 ‘‘TaxCol = 24 ‘‘折扣率 Dim FmoCol As Integer ‘‘金额列数 Dim FunDcol As Integer ‘‘单位折扣额列数 Dim FAcol As Integer ‘‘折扣额列 Dim Famt As Integer ‘‘项销金额列 Dim Fall As Integer ‘‘价税合计列 Dim FqCol As Integer ‘‘数量列 Dim FceCol As Integer ‘‘税率列 Dim Fauxqty As Integer ‘‘数量 Dim FCess As Integer ‘‘税率 Dim FAuxTaxPrice As Double ‘‘含税单价 Dim FTaxRate As Double ‘‘折扣率 Dim FAuxPriceDiscount As Double ‘‘实际含税单价 Dim Famount As Double ‘‘金额 Dim FUniDiscount As Double ‘‘单位折扣额 Dim FTaxAmount As Double ‘‘折扣额 Dim FTaxAmt As Double ‘‘销项金额 Dim FAllAmount As Double ‘‘价税合计 Dim FFAllAmount As Double ‘‘总合计 Dim FFTaxAmount As Double ‘‘折扣合计 Dim FFTaxAmt As Double ‘‘项销合计 Dim i As Integer Dim j As Integer Dim Alter(2) As Variant Dim TEntryCtl As Variant Dim FBool As Boolean TEntryCtl = m_BillTransfer.EntryCtl For i = 1 To UBound(TEntryCtl) If UCase(TEntryCtl(i).FieldName) = UCase("FAuxPriceDiscount") Then Colu = i ElseIf UCase(TEntryCtl(i).FieldName) = UCase("FAuxTaxPrice") Then FColu = i ElseIf UCase(TEntryCtl(i).FieldName) = UCase("FTaxRate") Then TaxCol = i ElseIf UCase(TEntryCtl(i).FieldName) = UCase("Famount") Then FmoCol = i ElseIf UCase(TEntryCtl(i).FieldName) = UCase("FUniDiscount") Then FunDcol = i ElseIf UCase(TEntryCtl(i).FieldName) = UCase("FTaxAmount") Then FAcol = i ElseIf UCase(TEntryCtl(i).FieldName) = UCase("FTaxAmt") Then Famt = i ElseIf UCase(TEntryCtl(i).FieldName) = UCase("FAllAmount") Then Fall = i ElseIf UCase(TEntryCtl(i).FieldName) = UCase("Fauxqty") Then FqCol = i ElseIf UCase(TEntryCtl(i).FieldName) = UCase("FCess") Then FceCol = i End If Next If Col = Colu Then ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘赋值过程 FAuxPriceDiscount = m_BillTransfer.GetGridText(Row, Colu) ‘‘实际含税单价 FAuxTaxPrice = m_BillTransfer.GetGridText(Row, FColu) ‘‘含税单价 Fauxqty = m_BillTransfer.GetGridText(Row, FqCol) ‘‘数量 FCess = m_BillTransfer.GetGridText(Row, FceCol) ‘‘税率 ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘计算过程 FTaxRate = (1 - FAuxPriceDiscount / FAuxTaxPrice) * 100 ‘‘折扣率 Famount = FAuxPriceDiscount * Fauxqty / (1 + FCess / 100) ‘‘金额=实际含税单价*数量/1.13 FUniDiscount = FAuxTaxPrice * FTaxRate / 100 ‘‘单位折扣额=含税单价*下浮 FTaxAmount = FUniDiscount * Fauxqty ‘‘折扣总额=折扣额*数量 FTaxAmt = Famount * FCess / 100 ‘‘销项税额=金额*税率 FAllAmount = FAuxPriceDiscount * Fauxqty ‘‘价税合计=实际含税单价*数量 FBool = m_BillTransfer.SetGridText(Row, TaxCol, FTaxRate) FBool = m_BillTransfer.SetGridText(Row, FmoCol, Famount) FBool = m_BillTransfer.SetGridText(Row, FunDcol, FUniDiscount) FBool = m_BillTransfer.SetGridText(Row, FAcol, FTaxAmount) FBool = m_BillTransfer.SetGridText(Row, Famt, FTaxAmt) FBool = m_BillTransfer.SetGridText(Row, Fall, FAllAmount) For j = 1 To 100 Alter(0) = m_BillTransfer.GetGridText(j, FAcol) If Alter(0) = "" Then FFAllAmount = FFAllAmount Exit For ElseIf Alter(0) > 0 Then FFAllAmount = FFAllAmount + Alter(0) End If Next FBool = m_BillTransfer.SetSumGridText(1, FAcol, FFAllAmount) For j = 1 To 100 Alter(1) = m_BillTransfer.GetGridText(j, Fall) If Alter(1) = "" Then FFTaxAmount = FFTaxAmount Exit For ElseIf Alter(1) > 0 Then FFTaxAmount = FFTaxAmount + Alter(1) End If Next FBool = m_BillTransfer.SetSumGridText(1, Fall, FFTaxAmount) For j = 1 To 100 Alter(2) = m_BillTransfer.GetGridText(j, Famt) If Alter(2) = "" Then FFTaxAmt = FFTaxAmt Exit For ElseIf Alter(2) > 0 Then FFTaxAmt = FFTaxAmt + Alter(2) End If Next FBool = m_BillTransfer.SetSumGridText(1, Famt, FFTaxAmt) End If End Sub
编程中值得注意的问题:
1)老单取分录体中的字段运用的变量主要为数组形式,但在声明过程中声明为未知变量即可,在程序中运用For语句进行列索引值的查询,将列名与字段名称运用转换为大写判定是否相同,方法如下:
For i = 1 To UBound(TEntryCtl) If UCase(TEntryCtl(i).FieldName) = UCase("FAuxPriceDiscount") Then Colu = i ElseIf UCase(TEntryCtl(i).FieldName) = UCase("FCess") Then FceCol = i End If Next
2)运用For循环更新结合SetSumGridText函数进行求和数据的更新;
本插件较为简单,但在开发过程中有些地方确实未考虑清楚,考虑清楚后实现较为容易!!!
原文地址:https://www.cnblogs.com/caipanlong123/p/11362777.html
时间: 2024-11-05 12:20:12