更新我已根据评论中的建议启用了Option Strict ON并修正了错误,但增值税仍未正确计算,此处是完整功能的GIST链接
我对增值税率无法正确计算存在问题,
MOT线应始终设置为0%,并且BOMOT线应根据客户增值税代码设置(此客户具有标准的20%增值税代码,因为您可以看到它已正确设置 < / p>
当我将客户更改为我的0级增值税客户时,代码再次正确计算,
现在,当我将客户从此更改为标准增值税客户时,它会重新计算错误,并在零线应为零时将MOT线更改为20%
以下是计算增值税的代码
Dim FPVATCode As String = 1
Dim FPVATRate As Decimal = 0
If c.LoadCode("V", FPVATCode, "") Then
FPVATRate = Val(c.Rec!a2)
End If
If customerVATRate <> -1 Then
If customerVATRate < FPVATRate Then
line.VCode = customerVATCode
Else
line.VCode = FPVATCode
End If
Else
line.VCode = FPVATCode
End If
Public Sub RecalculateDocumentPrices(ByVal NewCust As String) 'V749910 (163.18)
Dim newCustomer As New customer
newCustomer.LoadNewCustomer(NewCust)
' Get the customer VAT rate
Dim customerVATCode As String = newCustomer.GetVCode
Dim customerVATRate As Decimal = -1
Dim bAutoPartLinked As Boolean = Settings.AutoPartLinked
Dim c As New Codes
If c.LoadCode("V", customerVATCode, "") Then
customerVATRate = Val(c.Rec!a2)
End If
'L762946 (163.34) - only attempt recalculation if there are some lines on the document
If Not lines Is Nothing Then
For Each line As Line In lines
line.disc = 0
Select Case line.LineType
Case line.lineTypes.P, line.lineTypes.LT, line.lineTypes.SS, line.lineTypes.TA
'for a regular (ie. Non Branch Stock) product, get the price
If line.DescKey2 Is Nothing OrElse line.DescKey2.ToLower <> "branch" Then
''get the product price
Dim p As New Product
If p.LoadProduct(line.Part, , newCustomer.Rec!Cdisc, NewCust) Then 'V772656 (163.65) - pass the selling level of the new customer
'V749910 (163.19) - use the lower of the customer & product VAT rates
Dim productVATCode As String = p.Rec!Vcode
Dim productVATRate As Decimal = 0
If c.LoadCode("V", productVATCode, "") Then
productVATRate = Val(c.Rec!a2)
End If
If customerVATRate <> -1 Then
If customerVATRate < productVATRate Then
line.VCode = customerVATCode
Else
line.VCode = p.Rec!vcode
End If
Else
line.VCode = p.Rec!vcode
End If
'Remove VatIncCheck - V838410 (1.0.164.5)
'set the VatInclusive price if appropriate
'If newCustomer.IsVATInclusiveCustomer Then
' 'For a non linked system, add the VAT to the price
' Dim sellPrice As Decimal = p.sMSell
' If Not Settings.AutoPartLinked Then
' sellPrice *= Math.Round((1 + (line.vatRate / 100)), 2, MidpointRounding.AwayFromZero)
' End If
' line.IsVATInclusivePrice = True
' line.VatInclusivePrice = sellPrice
'Else
'V772656 (163.65) - was setting the unit price THEN the VAT Inc price THEN setting IsVatInclusivePrice to false. Therefore
'the unit price was being overwritten.
line.IsVATInclusivePrice = False
line.VatInclusivePrice = 0
If bAutoPartLinked Then 'L811755 (1.0.163.105)
line.unit = p.sMSell
End If
'End If
'Apply markon
CalcMarkon(line)
End If
Else
'for a Branch Stock product, perform a supplier enquiry to obtain the price
Dim awdTmp As New AutoworkDocument
Dim l As New Line
l.Part = line.Part
awdTmp.LookupLine(l)
'V749910 (163.19) - use the lower of the customer & product VAT rates
Dim productVATCode As Integer = 1
Dim productVATRate As Decimal = 0
If c.LoadCode("V", productVATCode, "") Then
productVATRate = Val(c.Rec!a2)
End If
If customerVATRate <> -1 Then
If customerVATRate < productVATRate Then
line.VCode = customerVATCode
Else
line.VCode = productVATCode
End If
Else
line.VCode = productVATCode
End If
'set the VatInclusive price if appropriate
If newCustomer.IsVATInclusiveCustomer Then
'Branch stock not available to Linked mode so just apply the vat
line.IsVATInclusivePrice = True
line.VatInclusivePrice = Math.Round(l.unit * (1 + (line.vatRate / 100)), 2, MidpointRounding.AwayFromZero)
Else
'V772656 (163.65) - was setting the unit price THEN the VAT Inc price THEN setting IsVatInclusivePrice to false. Therefore
'the unit price was being overwritten.
line.IsVATInclusivePrice = False
line.VatInclusivePrice = 0
line.unit = l.unit
End If
'Apply markon
CalcMarkon(line)
End If
Case line.lineTypes.FPP 'L829840 (1.0.163.123)
Case line.lineTypes.L 'V831093 (1.0.163.123)
'set the VatInclusive price if appropriate
If newCustomer.IsVATInclusiveCustomer Then 'V831093 (1.0.163.125)
'Branch stock not available to Linked mode so just apply the vat
line.IsVATInclusivePrice = True
line.VatInclusivePrice = Math.Round(line.unit * (1 + (line.vatRate / 100)), 2, MidpointRounding.AwayFromZero)
Else
'V772656 (163.65) - was setting the unit price THEN the VAT Inc price THEN setting IsVatInclusivePrice to false. Therefore
'the unit price was being overwritten.
line.IsVATInclusivePrice = False
line.VatInclusivePrice = 0
line.unit = line.unit
End If
Case line.lineTypes.FP
'get the selling price of the fixed price job
Dim cj As New CustomJobs
Dim ds As DataSet
Dim dv As DataView
ds = cj.LoadCustomJob(line.Part)
dv = ds.Tables("CustomJob").DefaultView
Dim dvHead As DataView = ds.Tables("JobHeader").DefaultView
If dvHead.Table.Rows.Count > 0 Then ''00518984 (1.0.163.105)
line.cost = CType(dvHead.Table.Rows(0)("FpCost"), Decimal)
'V749910 (163.19) - use the lower of the customer & product VAT rates
'V749910 (163.18) - If a VATInclusive line, set the VATInclusive price
If newCustomer.IsVATInclusiveCustomer Then
line.IsVATInclusivePrice = True
line.VatInclusivePrice = Math.Round(dvHead.Table.Rows(0)("FpSell") * (1 + (line.vatRate / 100)), 2, MidpointRounding.AwayFromZero)
Else
'V772656 (163.65) - was setting the unit price THEN the VAT Inc price THEN setting IsVatInclusivePrice to false. Therefore
'the unit price was being overwritten.
line.IsVATInclusivePrice = False
line.VatInclusivePrice = 0
line.unit = CType(dvHead.Table.Rows(0)("FpSell"), Decimal)
End If
End If ''00518984 END
Dim FPVATCode As String = CType(1, String)
Dim FPVATRate As Decimal = 0
If c.LoadCode("V", FPVATCode, "") Then
FPVATRate = CType(Val(c.Rec!a2), Decimal)
End If
If customerVATRate <> -1 Then
If customerVATRate < FPVATRate Then
line.VCode = CType(customerVATCode, Short)
Else
line.VCode = CType(FPVATCode, Short)
End If
Else
line.VCode = CType(FPVATCode, Short)
End If
Case line.lineTypes.CON
'just set the ISVatInclusive flag on this line. The consumables amount is calculated once all lines have been processed by the SaveSess().
line.VCode = customerVATCode
line.IsVATInclusivePrice = newCustomer.IsVATInclusiveCustomer
End Select
Next
End If
End Sub
答案 0 :(得分:0)
现已解决,增值税是根据错误表格中的产品计算的,
在方法中插入此条件并修复它,
'00518984 Calculates VAT for items in the labour table
Dim lB As New Product
Dim dv1 As DataView = lB.LabourSearch(line.Part)
If dv1.Table.Rows.Count > 0 Then
Dim dr1 As DataRow = dv1.ToTable.Rows(0)
Dim PVCode As Integer = dr1("VCode")
Beep()
line.VCode = PVCode
Else
Dim FPVATCode As String = CType(1, String)
Dim FPVATRate As Decimal = 0
If c.LoadCode("V", FPVATCode, "") Then
FPVATRate = CType(Val(c.Rec!a2), Decimal)
End If
line.VCode = customerVATCode
End If
'00518984 END