此主题相关图片如下:简易税额.png
此主题相关图片如下:应交税额.png
红色背景的测试有,可计算结果为啥出不来呢?
Select Case e.DataCol.Name
Case "年份","月份"
Dim dr As DataRow = e.DataRow
Dim filter As String = "[年份] = "& dr("年份") & "and [月份] = "& dr("月份") & " and 税率 <> 0.03 " '进项统计
Dim filter1 As String = "[年份] = "& dr("年份") & "and [月份] = "& dr("月份") & "and 税额 > 0 " '销项统计
Dim filter2 As String = "[年份] = "& dr("年份") & "and [月份] = "& dr("月份") & "And 税额 < 0 " '进项转出统计
Dim filter3 As String = "[年份] = "& dr("年份") & "and [月份] = "& dr("月份") & " and 税率 = 0.03 " '简易征收统计
For Each dc As DataCol In DataTables("税金统计").DataCols '计算简易征收的税
If dc.Name.Contains("简易销项金额") = True Then
MessageBox.Show(1) '测试用
dr("进项_金额") = DataTables("进项fa piao").SQLCompute("sum(金额)",filter1)
dr("进项_税额") = DataTables("进项fa piao").SQLCompute("sum(税额)",filter1)
dr("进项_价税合计") = DataTables("进项fa piao").SQLCompute("sum(金额 + 税额)",filter1)
dr("进项_份数") = DataTables("进项fa piao").SQLCompute("count(*)",filter1)
dr("进项转出_份数") = DataTables("进项fa piao").SQLCompute("count(*)",filter2)
dr("进项转出_税额") = DataTables("进项fa piao").SQLCompute("sum(税额)",filter2)
dr("销项_份数") = DataTables("销项fa piao").SQLCompute("count(*)",filter)
dr("销项_金额") = DataTables("销项fa piao").SQLCompute("sum(金额)",filter)
dr("销项_税额") = DataTables("销项fa piao").SQLCompute("sum(税额)",filter)
dr("销项_价税合计") = DataTables("销项fa piao").SQLCompute("sum(金额 + 税额)",filter)
dr("简易销项份数") = DataTables("销项fa piao").SQLCompute("count(*)",filter3)
dr("简易销项金额") = DataTables("销项fa piao").SQLCompute("sum(金额)",filter3)
dr("简易销项税额") = DataTables("销项fa piao").SQLCompute("sum(税额)",filter3)
dr("简易销项价税合计") = DataTables("销项fa piao").SQLCompute("sum(金额 + 税额)",filter3)
Dim dr1 As DataRow
Dim drs As List(of DataRow)
dr1 = e.DataTable.Find("[_SortKey] < " & e.DataRow("_SortKey"), "[_SortKey] Desc") '找出上一行
If dr1 Is Nothing Then '如果没有找到上一行,说明本行就是第一行
e.DataRow("正数是应交税额负数是留抵税额") = e.DataRow("销项_税额") - e.DataRow("进项_税额") - e.DataRow("进项转出_税额")
dr1 = e.DataRow
End If
drs = e.DataTable.Select("[_SortKey] >= " & dr1("_SortKey"), "[_SortKey]")
For i As Integer = 1 To drs.Count - 1 '重算余下行的余额
If drs(i-1)("正数是应交税额负数是留抵税额") >= 0 Then
drs(i)("正数是应交税额负数是留抵税额") = drs(i)("销项_税额") - drs(i)("进项_税额") - e.DataRow("进项转出_税额")
Else
drs(i)("正数是应交税额负数是留抵税额") = drs(i-1)("正数是应交税额负数是留抵税额") + drs(i)("销项_税额") - drs(i)("进项_税额")- e.DataRow("进项转出_税额")
End If
Next
If e.DataRow("正数是应交税额负数是留抵税额") < 0 Then
e.DataRow("应交税额") = e.DataRow("简易销项税额")
Else
MessageBox.Show("应交税额:" & e.DataRow("正数是应交税额负数是留抵税额")) '测试用
MessageBox.Show("简易销项税额:" & e.DataRow("简易销项税额")) '测试用
e.DataRow("应交税额") = e.DataRow("正数是应交税额负数是留抵税额") + e.DataRow("简易销项税额")
End If
Else
dr("进项_金额") = DataTables("进项fa piao").SQLCompute("sum(金额)",filter1)
dr("进项_税额") = DataTables("进项fa piao").SQLCompute("sum(税额)",filter1)
dr("进项_价税合计") = DataTables("进项fa piao").SQLCompute("sum(金额 + 税额)",filter1)
dr("进项_份数") = DataTables("进项fa piao").SQLCompute("count(*)",filter1)
dr("进项转出_份数") = DataTables("进项fa piao").SQLCompute("count(*)",filter2)
dr("进项转出_税额") = DataTables("进项fa piao").SQLCompute("sum(税额)",filter2)
dr("销项_份数") = DataTables("销项fa piao").SQLCompute("count(*)",filter)
dr("销项_金额") = DataTables("销项fa piao").SQLCompute("sum(金额)",filter)
dr("销项_税额") = DataTables("销项fa piao").SQLCompute("sum(税额)",filter)
dr("销项_价税合计") = DataTables("销项fa piao").SQLCompute("sum(金额 + 税额)",filter)
Dim dr1 As DataRow
Dim drs As List(of DataRow)
dr1 = e.DataTable.Find("[_SortKey] < " & e.DataRow("_SortKey"), "[_SortKey] Desc") '找出上一行
If dr1 Is Nothing Then '如果没有找到上一行,说明本行就是第一行
e.DataRow("正数是应交税额负数是留抵税额") = e.DataRow("销项_税额") - e.DataRow("进项_税额") - e.DataRow("进项转出_税额")
dr1 = e.DataRow
End If
drs = e.DataTable.Select("[_SortKey] >= " & dr1("_SortKey"), "[_SortKey]")
For i As Integer = 1 To drs.Count - 1 '重算余下行的余额
If drs(i-1)("正数是应交税额负数是留抵税额") >= 0 Then
drs(i)("正数是应交税额负数是留抵税额") = drs(i)("销项_税额") - drs(i)("进项_税额") - e.DataRow("进项转出_税额")
Else
drs(i)("正数是应交税额负数是留抵税额") = drs(i-1)("正数是应交税额负数是留抵税额") + drs(i)("销项_税额") - drs(i)("进项_税额")- e.DataRow("进项转出_税额")
End If
Next
If e.DataRow("正数是应交税额负数是留抵税额") < 0 Then
e.DataRow("应交税额") = Nothing
Else
e.DataRow("应交税额") = e.DataRow("正数是应交税额负数是留抵税额")
End If
End If
Next
End Select