Ustv, etc.
This commit is contained in:
@@ -379,7 +379,7 @@ Public Class usrCntlFaktAbrechnung
|
||||
Sub setControlsEnabled(pnl As Panel, pnlEnabled As Boolean)
|
||||
For Each c In pnl.Controls
|
||||
If c.GetType Is GetType(VERAG_PROG_ALLGEMEIN.MyTextBox) Or c.GetType Is GetType(VERAG_PROG_ALLGEMEIN.KdSearchBox) Then
|
||||
c.Enabled = IIf(cboFiliale._value = "5701" AndAlso VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("AMBAR_ALLE_RECHNUNGSEMPFÄNGER", "SDL"), True, pnlEnabled)
|
||||
c.Enabled = IIf(cboFiliale._value = "5701" AndAlso VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("AMBAR_ALLE_RECHNUNGSEMPFÄNGER", "SDL") Or (cboFiliale._value = "4817" And FIRMA.Firma_ID = 19 And RECHNUNG.DruckDatumZeit Is Nothing), True, pnlEnabled)
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
@@ -1208,9 +1208,10 @@ Public Class usrCntlFaktAbrechnung
|
||||
c = New DataGridViewTextBoxColumn() : c.Name = "DateiNameAufschub" : .Columns.Add(c)
|
||||
c = New DataGridViewTextBoxColumn() : c.Name = "Belegdaten" : .Columns.Add(c)
|
||||
c = New DataGridViewTextBoxColumn() : c.Name = "BerechnungsartPosInkludiert" : .Columns.Add(c)
|
||||
c = New DataGridViewTextBoxColumn() : c.Name = "ReverseCharge" : .Columns.Add(c)
|
||||
|
||||
|
||||
Dim dt As DataTable = SQL.loadDgvBySql(" SELECT [Offertenpositionen].[LeistungsNr],[Offertenpositionen].[LeistungsBez],[Anzahl],[Preis],[Offertenpositionen].[BerechnungsartNr],[BGebLeistungsNr],[BGebProzent],[BGebMinBetrag],Steuerpflichtig/*,[Geändert am],[Sachbearbeiter]*/,BerechnungsartPosInkludiert " &
|
||||
Dim dt As DataTable = SQL.loadDgvBySql(" SELECT [Offertenpositionen].[LeistungsNr],[Offertenpositionen].[LeistungsBez],[Anzahl],[Preis],[Offertenpositionen].[BerechnungsartNr],[BGebLeistungsNr],[BGebProzent],[BGebMinBetrag],Steuerpflichtig, ReverseCharge/*,[Geändert am],[Sachbearbeiter]*/,BerechnungsartPosInkludiert " &
|
||||
" FROM [Offertenpositionen] INNER JOIN [Leistungen] ON leistungen.LeistungsNr=Offertenpositionen.LeistungsNr " &
|
||||
" WHERE KundenNr='" & kdNr & "' and OffertenNr='" & OffertenNr & "' ORDER BY LeistungsNr ", "FMZOLL")
|
||||
|
||||
@@ -1266,6 +1267,7 @@ Public Class usrCntlFaktAbrechnung
|
||||
.Columns("BGebMinBetrag").Visible = VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM
|
||||
.Columns("Steuerpflichtig").Visible = VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM
|
||||
.Columns("BerechnungsartPosInkludiert").Visible = VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM
|
||||
.Columns("ReverseCharge").Visible = VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM
|
||||
' .Columns("Geändert am").Visible = False
|
||||
'.Columns("Sachbearbeiter").Visible = False
|
||||
|
||||
@@ -1287,7 +1289,7 @@ Public Class usrCntlFaktAbrechnung
|
||||
If True Then
|
||||
|
||||
dgvOfferteDetailsUebersicht.Rows.Add(r("LeistungsNr"), r("LeistungsBez"), r("Anzahl"), r("Preis"), r("BerechnungsartNr"), r("BGebLeistungsNr"), r("BGebProzent"), r("BGebMinBetrag"), steuerpflichtigTMP,
|
||||
DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, r("BerechnungsartPosInkludiert"))
|
||||
DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value, r("BerechnungsartPosInkludiert"), r("ReverseCharge"))
|
||||
|
||||
Else
|
||||
dgvOfferteDetailsUebersicht.Rows.Add(r("LeistungsNr"), r("LeistungsBez"), r("Anzahl"), r("Preis"), r("BerechnungsartNr"), DBNull.Value, DBNull.Value, DBNull.Value, steuerpflichtigTMP,
|
||||
@@ -1421,7 +1423,9 @@ Public Class usrCntlFaktAbrechnung
|
||||
End Try
|
||||
Try
|
||||
Dim landNr As String = ""
|
||||
Dim landBez = CheckLandNr_getLandBezFromLandNr(landNr)
|
||||
Dim landBez As String = ""
|
||||
Dim antrag As cUSTVAntrag = Nothing
|
||||
If FIRMA.Firma_ID = 19 AndAlso SPEDBUCH IsNot Nothing AndAlso SPEDBUCH.FilialenNr = 4817 Then landBez = CheckLandNr_getLandBezFromAntrag(landNr, antrag)
|
||||
|
||||
For Each r As DataGridViewRow In dgvOfferteDetailsUebersicht.Rows
|
||||
If r.Cells("Anzahl").Value IsNot DBNull.Value AndAlso Not IsNumeric(r.Cells("Anzahl").Value) Then r.Cells("Anzahl").Value = 0
|
||||
@@ -1431,13 +1435,20 @@ Public Class usrCntlFaktAbrechnung
|
||||
Dim POS As New VERAG_PROG_ALLGEMEIN.cRechnungsausgangPositionen
|
||||
POS.LeistungsNr = r.Cells("LeistungsNr").Value
|
||||
POS.LeistungsBez = If(r.Cells("LeistungsBez").Value, "")
|
||||
|
||||
|
||||
|
||||
' POS.IndexZkteing = r.Cells("IndexZkteing").Value
|
||||
POS.BerechnungsartNr = r.Cells("BerechnungsartNr").Value
|
||||
POS.Preis = If(r.Cells("Preis").Value Is DBNull.Value, 0, CDbl(r.Cells("Preis").Value.ToString.Replace(".", "")))
|
||||
POS.Anzahl = If(r.Cells("Anzahl").Value Is DBNull.Value, 0, r.Cells("Anzahl").Value)
|
||||
|
||||
'-----------------------MWST-Abrechnung! + Kompat. zu FM-Zoll
|
||||
setMWSTABRfromSPEDinPOS(r, POS, landNr, landBez)
|
||||
If FIRMA.Firma_ID = 19 Then
|
||||
Dim isRC As Boolean = If(r.Cells("ReverseCharge").Value IsNot DBNull.Value, r.Cells("ReverseCharge").Value, False)
|
||||
setMWSTABRfromSPEDinPOS(r, POS, landNr, landBez, antrag)
|
||||
End If
|
||||
|
||||
'-----------------------MWST-Abrechnung! + Kompat. zu FM-Zoll
|
||||
|
||||
If POS.Anzahl = 0 And POS.BerechnungsartNr = 8 And POS.Preis <> 0 Then
|
||||
@@ -2370,7 +2381,7 @@ Public Class usrCntlFaktAbrechnung
|
||||
If RECHNUNG.RechnungSprache = "DE" Or FindPOS.LeistungsBez Is Nothing Then FindPOS.LeistungsBez = "Vorlageprovision"
|
||||
'RECHNUNG.POSITIONEN.Add(FindPOS)
|
||||
FindPOS.Anzahl = 1
|
||||
FindPOS.Preis = Math.round(Vorlageprovision_Berechnungbetrag * (RECHNUNG.Vorlageprovision_Proz), 2) 'Int(Vorlageprovision_Berechnungbetrag * (RECHNUNG.Vorlageprovision_Proz) * 10 + 0.5) / 10
|
||||
FindPOS.Preis = Math.Round(Vorlageprovision_Berechnungbetrag * (RECHNUNG.Vorlageprovision_Proz), 2) 'Int(Vorlageprovision_Berechnungbetrag * (RECHNUNG.Vorlageprovision_Proz) * 10 + 0.5) / 10
|
||||
'...und der Wert gesetzt.
|
||||
|
||||
initSteuerbetraege(RECHNUNG, FindPOS)
|
||||
@@ -2415,7 +2426,7 @@ Public Class usrCntlFaktAbrechnung
|
||||
If RECHNUNG.RechnungSprache = "DE" Or FindPOS.LeistungsBez Is Nothing Then FindPOS.LeistungsBez = "Kapitalbereitstellung"
|
||||
'RECHNUNG.POSITIONEN.Add(FindPOS)
|
||||
FindPOS.Anzahl = 1
|
||||
FindPOS.Preis = Math.round(Vorlageprovision_Berechnungbetrag * (RECHNUNG.Vorlageprovision_Proz), 2) ' Int(Vorlageprovision_Berechnungbetrag * (RECHNUNG.Vorlageprovision_Proz) * 10 + 0.5) / 10
|
||||
FindPOS.Preis = Math.Round(Vorlageprovision_Berechnungbetrag * (RECHNUNG.Vorlageprovision_Proz), 2) ' Int(Vorlageprovision_Berechnungbetrag * (RECHNUNG.Vorlageprovision_Proz) * 10 + 0.5) / 10
|
||||
'...und der Wert gesetzt.
|
||||
|
||||
initSteuerbetraege(RECHNUNG, FindPOS)
|
||||
@@ -2453,7 +2464,7 @@ Public Class usrCntlFaktAbrechnung
|
||||
|
||||
For Each POS In RECHNUNG.POSITIONEN
|
||||
' Dim BGebErrBetrag As Double = Int(If(If(POS.BGebBgl, 0), If(POS.Preis, 0) * If(POS.Anzahl, 0)) * If(POS.BGebProzent, 0) * 10 + 0.5) / 10
|
||||
Dim BGebErrBetrag As Double = Math.round(If(POS.BGebBgl IsNot Nothing, POS.BGebBgl, getNumeric(POS.Preis) * getNumeric(POS.Anzahl)) * getNumeric(POS.BGebProzent), 2) 'Int(If(POS.BGebBgl IsNot Nothing, POS.BGebBgl, getNumeric(POS.Preis) * getNumeric(POS.Anzahl)) * getNumeric(POS.BGebProzent) * 10 + 0.5) / 10
|
||||
Dim BGebErrBetrag As Double = Math.Round(If(POS.BGebBgl IsNot Nothing, POS.BGebBgl, getNumeric(POS.Preis) * getNumeric(POS.Anzahl)) * getNumeric(POS.BGebProzent), 2) 'Int(If(POS.BGebBgl IsNot Nothing, POS.BGebBgl, getNumeric(POS.Preis) * getNumeric(POS.Anzahl)) * getNumeric(POS.BGebProzent) * 10 + 0.5) / 10
|
||||
|
||||
|
||||
curBGebBetrag = 0
|
||||
@@ -2537,7 +2548,7 @@ Public Class usrCntlFaktAbrechnung
|
||||
|
||||
If (BGebLeistungsNr > 0 AndAlso BGebProzent > 0 AndAlso BGebBgl <> 0) Then
|
||||
|
||||
Dim Betrag As Double = Math.round(BGebBgl * BGebProzent, 1)
|
||||
Dim Betrag As Double = Math.Round(BGebBgl * BGebProzent, 1)
|
||||
For Each o In OFFERTE.POSITIONEN
|
||||
If o.LeistungsNr = BGebLeistungsNr Then
|
||||
|
||||
@@ -4449,38 +4460,166 @@ Nächste_Textzeile_lesen:
|
||||
Return landbez
|
||||
End Function
|
||||
|
||||
Private Sub setMWSTABRfromSPEDinPOS(r As DataGridViewRow, POS As cRechnungsausgangPositionen, LandNr As String, LandBez As String)
|
||||
Private Function CheckLandNr_getLandBezFromAntrag(ByRef LandNr As String, ByRef Antrag As cUSTVAntrag) As String
|
||||
|
||||
Dim landbez As String = ""
|
||||
If SPEDBUCH Is Nothing Then Return landbez
|
||||
If SPEDBUCH.FilialenNr = 4817 AndAlso SPEDBUCH.AbfertigungsNr > 0 And FIRMA.Firma_ID = 19 Then
|
||||
|
||||
|
||||
Dim antragsID As Integer = CInt(SQL.getValueTxtBySql("SELECT UStVAn_ID FROM tblUStVAntrag WHERE FilialenNr = " & SPEDBUCH.FilialenNr & " AND AbfertigungsNr = " & SPEDBUCH.AbfertigungsNr, "FMZOLL",,, "-1"))
|
||||
|
||||
If antragsID > 0 Then
|
||||
Dim MWSTAntrag As New cUSTVAntrag(antragsID)
|
||||
LandNr = MWSTAntrag.UStVAn_LandNr
|
||||
landbez = SQL.getValueTxtBySql("select LandKz from [Länderverzeichnis für die Außenhandelsstatistik] where LandNr = " & MWSTAntrag.UStVAn_LandNr, "FMZOLL")
|
||||
Antrag = MWSTAntrag
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
Return landbez
|
||||
|
||||
End Function
|
||||
|
||||
Private Sub setMWSTABRfromSPEDinPOS(r As DataGridViewRow, POS As cRechnungsausgangPositionen, LandNr As String, LandBez As String, Optional antrag As cUSTVAntrag = Nothing, Optional isVZ As Boolean = False)
|
||||
|
||||
|
||||
If SPEDBUCH.Abfertigungsart = 114 Or SPEDBUCH.Abfertigungsart = 115 Or SPEDBUCH.Abfertigungsart = 10 Then
|
||||
|
||||
Dim LeistungsBez = r.Cells("LeistungsBez").Value
|
||||
If LeistungsBez <> "" Then
|
||||
Dim isMWST As Boolean = False
|
||||
If LandBez <> "" AndAlso LandNr <> "" Then
|
||||
If SPEDBUCH.Packstücke.ToString.Replace("Mehrwertsteuerrückerstattung " & LandNr, "MWSt-Rückerstattung " & LandBez).StartsWith(LeistungsBez.ToString) AndAlso LeistungsBez.ToString.StartsWith("MWSt-Rückerstattung") Then isMWST = True
|
||||
Dim kdNr = IIf(RECHNUNG.RechnungsKundenNr > 0, RECHNUNG.RechnungsKundenNr, kdFirmaRechnungAn.KdNr)
|
||||
Dim isRMC = IIf(kdNr = 150000 AndAlso antrag.UStVAn_AntragArt = "MWST", True, False)
|
||||
|
||||
Dim sumRMC As Double = 0
|
||||
Dim sumFremdBeleg As Double = 0
|
||||
|
||||
If antrag IsNot Nothing AndAlso LandBez <> "" AndAlso antrag.UStVAn_AntragArt <> "" Then
|
||||
|
||||
If antrag.UStVAn_AntragArt <> "MWST" Then isRMC = False
|
||||
|
||||
Dim LandISO2 = ""
|
||||
|
||||
If LandBez.Length = 2 Then
|
||||
LandISO2 = LandBez
|
||||
ElseIf LandBez.Length = 3 Then
|
||||
LandISO2 = VERAG_PROG_ALLGEMEIN.cProgramFunctions.getISO2LandFromISO3Land(LandBez)
|
||||
ElseIf LandBez.Length = 1 Then
|
||||
LandISO2 = VERAG_PROG_ALLGEMEIN.cProgramFunctions.getISO2LandFromISO1Land(LandBez)
|
||||
End If
|
||||
|
||||
|
||||
If LeistungsBez.ToString.Contains(LandISO2) AndAlso LeistungsBez.ToString.ToLower.StartsWith(antrag.UStVAn_AntragArt.ToString.ToLower) AndAlso IIf(isVZ, LeistungsBez.ToString.Contains("VZ"), Not LeistungsBez.ToString.Contains("VZ")) Then
|
||||
|
||||
'wenn RMC, dann ebenfalls unterscheiden!
|
||||
|
||||
If isRMC Then
|
||||
|
||||
'aus AntragsPOS die
|
||||
|
||||
For Each ANTR_POS As cUStVPositionen In antrag.POSITIONEN
|
||||
|
||||
If ANTR_POS.UStVPo_Leistender.ToString.ToUpper.StartsWith("RMC") Then
|
||||
sumRMC += ANTR_POS.UStVPo_USteuerbetragEUR
|
||||
Else
|
||||
sumFremdBeleg += ANTR_POS.UStVPo_USteuerbetragEUR
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
'SPEDBUCH.Abfertigungsart = 114 -> EU
|
||||
'SPEDBUCH.Abfertigungsart = 115 -> DL Drittland
|
||||
|
||||
Dim BEZ_LAND_RMC As String = ""
|
||||
Select Case SPEDBUCH.Abfertigungsart
|
||||
Case 114 : BEZ_LAND_RMC = "00-"
|
||||
Case 115 : BEZ_LAND_RMC = "DL-00"
|
||||
End Select
|
||||
|
||||
|
||||
If LeistungsBez.ToString.Contains("RMC-RG") AndAlso LeistungsBez.ToString.Contains(BEZ_LAND_RMC) Then
|
||||
isMWST = True
|
||||
GoTo mwst
|
||||
ElseIf LeistungsBez.ToString.Contains("FREMD-RG") AndAlso LeistungsBez.ToString.Contains(BEZ_LAND_RMC) Then
|
||||
isMWST = True
|
||||
GoTo mwst
|
||||
End If
|
||||
|
||||
Else
|
||||
isMWST = True
|
||||
GoTo mwst
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If LandBez <> "" AndAlso LandNr <> "" Then
|
||||
If SPEDBUCH.Packstücke.ToString.Replace("Mehrwertsteuerrückerstattung " & LandNr, "MWSt-Rückerstattung " & LandBez).StartsWith(LeistungsBez.ToString) AndAlso LeistungsBez.ToString.StartsWith("MWSt-Rückerstattung") Then
|
||||
isMWST = True
|
||||
GoTo mwst
|
||||
End If
|
||||
|
||||
|
||||
Else
|
||||
If SPEDBUCH.Packstücke.ToString().Replace("Mehrwertsteuerrückerstattung ", "MWSt-Rückerstattung ").StartsWith(LeistungsBez.ToString) AndAlso LeistungsBez.ToString.StartsWith("MWSt-Rückerstattung") Then isMWST = True
|
||||
If SPEDBUCH.Packstücke.ToString().Replace("Mehrwertsteuerrückerstattung ", "MWSt-Rückerstattung ").StartsWith(LeistungsBez.ToString) AndAlso LeistungsBez.ToString.StartsWith("MWSt-Rückerstattung") Then
|
||||
isMWST = True
|
||||
GoTo mwst
|
||||
End If
|
||||
End If
|
||||
mwst:
|
||||
|
||||
If isMWST Then
|
||||
POS.Anzahl = 1
|
||||
|
||||
If POS.Preis = 0 Then
|
||||
POS.Preis = IIf(SPEDBUCH.Rechnungsbetrag Is Nothing, 0, SPEDBUCH.Rechnungsbetrag) * -1
|
||||
|
||||
If antrag IsNot Nothing AndAlso antrag.UStVAn_ID > 0 Then
|
||||
|
||||
If POS.Preis = 0 Then
|
||||
|
||||
Dim GesamtUSteuerEUR As Double = SQL.DLookup("isnull(sum(UStVPo_USteuerbetragEUR),0)", "tblUStVPositionen", "UStVAn_ID='" & antrag.UStVAn_ID & "'", "FMZOLL", "0")
|
||||
Dim GesamtErstattungEUR As Double = SQL.DLookup("isnull(sum(UStVEr_USteuerbetragEUR),0)", "tblUStVErstattung", "UStVAn_ID='" & antrag.UStVAn_ID & "'", "FMZOLL", "0")
|
||||
|
||||
If isRMC Then
|
||||
If LeistungsBez.ToString.Contains("RMC-RG") AndAlso sumRMC <> 0 Then
|
||||
POS.Preis = sumRMC * -1
|
||||
ElseIf LeistungsBez.ToString.Contains("FREMD-RG") AndAlso sumFremdBeleg <> 0 Then
|
||||
POS.Preis = sumFremdBeleg * -1
|
||||
End If
|
||||
|
||||
Else
|
||||
|
||||
Dim DiffernezbetragEUR As Double = GesamtUSteuerEUR - GesamtErstattungEUR
|
||||
If DiffernezbetragEUR <> 0 Then
|
||||
POS.Preis = DiffernezbetragEUR * -1
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
|
||||
If r.Cells("BGebLeistungsNr").Value IsNot Nothing AndAlso Not IsDBNull(r.Cells("BGebLeistungsNr").Value) AndAlso r.Cells("BGebProzent").Value IsNot Nothing AndAlso Not IsDBNull(r.Cells("BGebProzent").Value) Then
|
||||
|
||||
Dim OffertNr As Integer = IIf(IsNumeric(RECHNUNG.OffertenNr), RECHNUNG.OffertenNr, (SPEDBUCH.Abfertigungsart - 100))
|
||||
If OffertNr < 0 Then OffertNr = 15
|
||||
|
||||
Dim OFFERTE As New VERAG_PROG_ALLGEMEIN.cOfferte(RECHNUNG.KundenNrZentrale, OffertNr, True)
|
||||
Dim OFFERTE As New VERAG_PROG_ALLGEMEIN.cOfferte(IIf(RECHNUNG.RechnungsKundenNr > 0, RECHNUNG.RechnungsKundenNr, kdFirmaRechnungAn.KdNr), OffertNr, True)
|
||||
Call prBearbGeb(POS, OFFERTE, RECHNUNG, r.Cells("BGebLeistungsNr").Value, r.Cells("BGebProzent").Value, POS.Preis * If(RECHNUNG.Vorzeichen = "-", -1, 1))
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user