Fakt, Sammelrechung, etc.

This commit is contained in:
2025-08-05 11:13:30 +02:00
parent 0f98cbcc8b
commit df19ba3c22
3 changed files with 106 additions and 174 deletions

View File

@@ -389,7 +389,7 @@ Public Class frmFaktEmail
If SPEDBUCH.hasEntry AndAlso (SPEDBUCH.Abfertigungsart = 114 Or SPEDBUCH.Abfertigungsart = 115 Or SPEDBUCH.Abfertigungsart = 10) Then If SPEDBUCH.hasEntry AndAlso (SPEDBUCH.Abfertigungsart = 114 Or SPEDBUCH.Abfertigungsart = 115 Or SPEDBUCH.Abfertigungsart = 10) Then
Dim USTV_ANTRAG As New cUSTVAntrag(RECHNUNG.ErfassungsNr) Dim USTV_ANTRAG As New cUSTVAntrag(RECHNUNG.ErfassungsNr)
If RECHNUNG.VermittlerKundenNr = 150000 Or RECHNUNG.VermittlerKundenNr = 140000 Then If RECHNUNG.VermittlerKundenNr = 150000 Or RECHNUNG.VermittlerKundenNr = 140000 Or RECHNUNG.VermittlerKundenNr.ToString.Substring(0, 2) = 18 Then
replaceKZ("nichtRMC", TextHTML) replaceKZ("nichtRMC", TextHTML)
TextHTML = TextHTML.ToString.Replace("%RMC:", "") : TextHTML = TextHTML.ToString.Replace("RMC%", "") TextHTML = TextHTML.ToString.Replace("%RMC:", "") : TextHTML = TextHTML.ToString.Replace("RMC%", "")
@@ -1129,7 +1129,7 @@ Public Class frmFaktEmail
list3megered = FormularManagerNEU.MergePdfFiles(myListPOSLIST, zielPfadZusammenfassung_POSListe) list3megered = FormularManagerNEU.MergePdfFiles(myListPOSLIST, zielPfadZusammenfassung_POSListe)
End If End If
If RECHNUNG.VermittlerKundenNr = 150000 Or RECHNUNG.VermittlerKundenNr = 140000 Then If RECHNUNG.VermittlerKundenNr = 150000 Or RECHNUNG.VermittlerKundenNr = 140000 Or RECHNUNG.VermittlerKundenNr.ToString.Substring(0, 2) = 18 Then
'bei RMC und Durmaz doch wieder alles in einem Anhang und ohne LIEFERANTENRECHNUNGEN !!!!!!!! 'bei RMC und Durmaz doch wieder alles in einem Anhang und ohne LIEFERANTENRECHNUNGEN !!!!!!!!
'For Each a In myListLiefereranten 'For Each a In myListLiefereranten

View File

@@ -356,7 +356,7 @@ Public Class frmFaktSammelRgDrucken
End If End If
Dim f As New frmFaktEmail(cboFirma._value, Sammelrechung, CDate(txtRechnungsdatum.Text), CDate(txtRechnungsdatum.Text), cboPrinter.Text, RG_DRUCK, cbxEinzelAnlagen.Checked, cbxSammelbericht.Checked, getSelectionKdNr_Simple, -1, Nothing, cboSB._value,, getAvisoIds, cbxEVOLOG.Checked, cbxTransFerry.Checked, cboFaktGrp._value, cboAbfertigungsart._value, MDMKopiedrucken) Dim f As New frmFaktEmail(cboFirma._value, Sammelrechung, CDate(txtZeitraumBis.Text), CDate(txtRechnungsdatum.Text), cboPrinter.Text, RG_DRUCK, cbxEinzelAnlagen.Checked, cbxSammelbericht.Checked, getSelectionKdNr_Simple, -1, Nothing, cboSB._value,, getAvisoIds, cbxEVOLOG.Checked, cbxTransFerry.Checked, cboFaktGrp._value, cboAbfertigungsart._value, MDMKopiedrucken)
f.ShowDialog(Me) f.ShowDialog(Me)
MyDatagridview1.GetOrder() MyDatagridview1.GetOrder()
initDGV() initDGV()

View File

@@ -1181,6 +1181,7 @@ Public Class usrCntlFaktAbrechnung
Dim landBez As String = "" Dim landBez As String = ""
Dim antrag As cUSTVAntrag = Nothing Dim antrag As cUSTVAntrag = Nothing
Dim summeRMC As Double = 0 Dim summeRMC As Double = 0
Dim summeFremd As Double = 0
If FIRMA IsNot Nothing AndAlso FIRMA.Firma_ID = 19 AndAlso SPEDBUCH IsNot Nothing AndAlso SPEDBUCH.FilialenNr = 4817 Then landBez = CheckLandNr_getLandBezFromAntrag(landNr, antrag) If FIRMA IsNot Nothing AndAlso FIRMA.Firma_ID = 19 AndAlso SPEDBUCH IsNot Nothing AndAlso SPEDBUCH.FilialenNr = 4817 Then landBez = CheckLandNr_getLandBezFromAntrag(landNr, antrag)
Dim addFields As String = "" Dim addFields As String = ""
@@ -1279,7 +1280,7 @@ Public Class usrCntlFaktAbrechnung
If FIRMA IsNot Nothing AndAlso FIRMA.Firma_ID = 19 AndAlso RECHNUNG.DruckDatumZeit Is Nothing Then If FIRMA IsNot Nothing AndAlso FIRMA.Firma_ID = 19 AndAlso RECHNUNG.DruckDatumZeit Is Nothing Then
Dim isRC As Boolean = If(r.Cells("ReverseCharge").Value IsNot DBNull.Value, r.Cells("ReverseCharge").Value, False) Dim isRC As Boolean = If(r.Cells("ReverseCharge").Value IsNot DBNull.Value, r.Cells("ReverseCharge").Value, False)
setMWSTABRfromSPEDinPOS(r, landNr, landBez, summeRMC, False, antrag, isVZ) setMWSTABRfromSPEDinPOS(r, landNr, landBez, summeRMC, summeFremd, False, False, antrag, isVZ)
End If End If
Catch ex As Exception : End Try Catch ex As Exception : End Try
@@ -1390,25 +1391,46 @@ Public Class usrCntlFaktAbrechnung
If Not loaded Then Exit Sub If Not loaded Then Exit Sub
If FIRMA IsNot Nothing AndAlso FIRMA.Firma_ID = 19 AndAlso SPEDBUCH IsNot Nothing AndAlso SPEDBUCH.FilialenNr = 4817 AndAlso RECHNUNG.DruckDatumZeit Is Nothing AndAlso e.ColumnIndex = 3 Then Dim posSet As Boolean = False
If FIRMA IsNot Nothing AndAlso FIRMA.Firma_ID = 19 AndAlso SPEDBUCH IsNot Nothing AndAlso SPEDBUCH.FilialenNr = 4817 AndAlso RECHNUNG.DruckDatumZeit Is Nothing AndAlso (e.ColumnIndex = 3 Or e.ColumnIndex = 2) Then
Dim landNr As String = "" Dim landNr As String = ""
Dim landBez As String = "" Dim landBez As String = ""
Dim antrag As cUSTVAntrag = Nothing Dim antrag As cUSTVAntrag = Nothing
Dim summeRMC As Double = 0
landBez = CheckLandNr_getLandBezFromAntrag(landNr, antrag) landBez = CheckLandNr_getLandBezFromAntrag(landNr, antrag)
Dim summeRMC As Double = 0
Dim summeFremd As Double = 0
Dim containRMC As Boolean = False Dim containRMC As Boolean = False
Dim containFremd As Boolean = False Dim containFremd As Boolean = False
Dim sumOffertRMC As Double = 0
Dim sumOffertFremd As Double = 0
Dim minBetragRMC As Double = 0
Dim minBetragFremd As Double = 0
Dim bearbNrRMC As Integer = 0
Dim bearbNrFremd As Integer = 0
For Each r In dgvOfferteDetailsUebersicht.Rows For Each r In dgvOfferteDetailsUebersicht.Rows
If r.Cells("LeistungsBez").Value.Contains("Fremd-RG") AndAlso r.Cells("Anzahl").Value > 0 Then If r.Cells("LeistungsBez").Value.Contains("Fremd-RG") AndAlso r.Cells("Anzahl").Value <> 0 AndAlso IsNumeric(r.Cells("Preis").Value) Then
containFremd = True containFremd = True
bearbNrFremd = IIf(Not IsDBNull(r.Cells("BGebLeistungsNr").Value), r.Cells("BGebLeistungsNr").Value, 0)
minBetragFremd = IIf(Not IsDBNull(r.Cells("BGebMinBetrag").Value), r.Cells("BGebMinBetrag").Value, 0)
sumOffertFremd = Math.Round(r.Cells("Anzahl").Value * CDbl(r.Cells("Preis").Value * r.Cells("BGebProzent").Value), 2)
End If End If
If r.Cells("LeistungsBez").Value.Contains("RMC-RG") AndAlso r.Cells("Anzahl").Value > 0 Then If r.Cells("LeistungsBez").Value.Contains("RMC-RG") AndAlso r.Cells("Anzahl").Value <> 0 AndAlso IsNumeric(r.Cells("Preis").Value) Then
containRMC = True containRMC = True
bearbNrRMC = IIf(Not IsDBNull(r.Cells("BGebLeistungsNr").Value), r.Cells("BGebLeistungsNr").Value, 0)
sumOffertRMC = Math.Round(r.Cells("Anzahl").Value * CDbl(r.Cells("Preis").Value * r.Cells("BGebProzent").Value), 2)
minBetragRMC = IIf(Not IsDBNull(r.Cells("BGebMinBetrag").Value), r.Cells("BGebMinBetrag").Value, 0)
End If End If
Next Next
@@ -1416,23 +1438,18 @@ Public Class usrCntlFaktAbrechnung
For Each r In dgvOfferteDetailsUebersicht.Rows For Each r In dgvOfferteDetailsUebersicht.Rows
setMWSTABRfromSPEDinPOS(r, landNr, landBez, summeRMC, (containRMC AndAlso containFremd), antrag, isVZ, True) If r.Cells("Anzahl").Value <> 0 And r.Cells("Preis").Value <> 0 AndAlso IsNumeric(r.Cells("Preis").Value) AndAlso r.Cells("LeistungsNr").Value <> bearbNrRMC Then
setMWSTABRfromSPEDinPOS(r, landNr, landBez, summeRMC, summeFremd, (containRMC AndAlso containFremd), posSet, antrag, isVZ, True, sumOffertRMC, minBetragRMC, sumOffertFremd, minBetragFremd)
'If posSet Then Exit For
End If
Next Next
'Dim datarow As DataGridViewRow = dgvOfferteDetailsUebersicht.Rows(e.RowIndex)
'-----------------------MWST-Abrechnung! + Kompat. zu FM-Zoll
'If FIRMA IsNot Nothing AndAlso FIRMA.Firma_ID = 19 AndAlso RECHNUNG.DruckDatumZeit Is Nothing Then
' Dim isRC As Boolean = If(r.Cells("ReverseCharge").Value IsNot DBNull.Value, r.Cells("ReverseCharge").Value, False)
'End If
'-----------------------MWST-Abrechnung! + Kompat. zu FM-Zoll
End If End If
przRefreshDGV_Positionen() przRefreshDGV_Positionen()
End Sub End Sub
Sub przRefreshDGV_Positionen() Sub przRefreshDGV_Positionen()
@@ -2482,7 +2499,7 @@ Public Class usrCntlFaktAbrechnung
If RECHNUNG.RechnungSprache = "DE" Or FindPOS.LeistungsBez Is Nothing Then FindPOS.LeistungsBez = "Vorlageprovision" If RECHNUNG.RechnungSprache = "DE" Or FindPOS.LeistungsBez Is Nothing Then FindPOS.LeistungsBez = "Vorlageprovision"
'RECHNUNG.POSITIONEN.Add(FindPOS) 'RECHNUNG.POSITIONEN.Add(FindPOS)
FindPOS.Anzahl = 1 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. '...und der Wert gesetzt.
initSteuerbetraege(RECHNUNG, FindPOS) initSteuerbetraege(RECHNUNG, FindPOS)
@@ -2527,7 +2544,7 @@ Public Class usrCntlFaktAbrechnung
If RECHNUNG.RechnungSprache = "DE" Or FindPOS.LeistungsBez Is Nothing Then FindPOS.LeistungsBez = "Kapitalbereitstellung" If RECHNUNG.RechnungSprache = "DE" Or FindPOS.LeistungsBez Is Nothing Then FindPOS.LeistungsBez = "Kapitalbereitstellung"
'RECHNUNG.POSITIONEN.Add(FindPOS) 'RECHNUNG.POSITIONEN.Add(FindPOS)
FindPOS.Anzahl = 1 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. '...und der Wert gesetzt.
initSteuerbetraege(RECHNUNG, FindPOS) initSteuerbetraege(RECHNUNG, FindPOS)
@@ -2565,7 +2582,7 @@ Public Class usrCntlFaktAbrechnung
For Each POS In RECHNUNG.POSITIONEN 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 = 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 curBGebBetrag = 0
@@ -2642,7 +2659,7 @@ Public Class usrCntlFaktAbrechnung
End Function End Function
Private Sub prBearbGeb_NEW(r As DataGridViewRow, OFFERTE As cOfferte, RE As cRechnungsausgang, BGebLeistungsNr As Integer, BGebProzent As Double, BGebMinBetrag As Double, BGebBgl As Integer, ByRef summeRMCBearb As Double, isRMC As Boolean, isFREMD As Boolean, FremdUndRMC As Boolean, changed As Boolean) Private Sub prBearbGeb_NEW(r As DataGridViewRow, OFFERTE As cOfferte, RE As cRechnungsausgang, BGebLeistungsNr As Integer, BGebProzent As Double, BGebMinBetrag As Double, BGebBgl As Integer, ByRef summeRMCBearb As Double, ByRef summeFremdBearb As Double, isRMC As Boolean, isFREMD As Boolean, FremdUndRMC As Boolean, ByRef changed As Boolean, sumRMC As Double, sumOffertRMC As Double, sumFremd As Double, sumOffertFremd As Double, sumVZAntrag As Double, ByRef POSChanged As Boolean)
If r.Cells("Anzahl").Value <> 0 Then If r.Cells("Anzahl").Value <> 0 Then
@@ -2653,7 +2670,7 @@ Public Class usrCntlFaktAbrechnung
Dim curBGebMinBetrag = BGebMinBetrag Dim curBGebMinBetrag = BGebMinBetrag
Dim curBGebErrBetrag As Double = Math.round(BGebBgl * BGebProzent, 1) Dim curBGebErrBetrag As Double = Math.Round(BGebBgl * BGebProzent, 1)
Dim curBGebBetrag As Double = 0 Dim curBGebBetrag As Double = 0
curBGebBetrag = curBGebErrBetrag curBGebBetrag = curBGebErrBetrag
@@ -2663,15 +2680,19 @@ Public Class usrCntlFaktAbrechnung
If curBGebMinBetrag < 0 Then If curBGebMinBetrag < 0 Then
curBGebMinBetrag = 0 - curBGebMinBetrag 'Vorzeichen in Plus ändern. curBGebMinBetrag = 0 - curBGebMinBetrag 'Vorzeichen in Plus ändern.
End If End If
'Größeren Betrag bereitstellen. 'Größeren Betrag bereitstellen.
If curBGebErrBetrag > curBGebMinBetrag Then If curBGebErrBetrag > curBGebMinBetrag Then
curBGebBetrag = curBGebErrBetrag 'Errechneten Betrag verwenden curBGebBetrag = curBGebErrBetrag 'Errechneten Betrag verwenden
summeRMCBearb += If(r.Cells("LeistungsBez").Value.Contains("Fremd-RG") OrElse r.Cells("LeistungsBez").Value.Contains("RMC-RG"), curBGebErrBetrag, 0) summeFremdBearb += If(r.Cells("LeistungsBez").Value.Contains("Fremd-RG"), curBGebErrBetrag, 0)
summeRMCBearb += If(r.Cells("LeistungsBez").Value.Contains("RMC-RG"), curBGebErrBetrag, 0)
Else Else
curBGebBetrag = curBGebMinBetrag 'Mindestbetrag verwenden curBGebBetrag = curBGebMinBetrag 'Mindestbetrag verwenden
summeRMCBearb += If(r.Cells("LeistungsBez").Value.Contains("Fremd-RG") OrElse r.Cells("LeistungsBez").Value.Contains("RMC-RG"), curBGebErrBetrag, 0) summeFremdBearb += If(r.Cells("LeistungsBez").Value.Contains("Fremd-RG"), curBGebErrBetrag, 0)
summeRMCBearb += If(r.Cells("LeistungsBez").Value.Contains("Fremd-RG"), curBGebErrBetrag, 0)
minBetragRMCUsed = IIf(r.Cells("LeistungsBez").Value.Contains("Fremd-RG") OrElse r.Cells("LeistungsBez").Value.Contains("RMC-RG"), True, False) minBetragRMCUsed = IIf(r.Cells("LeistungsBez").Value.Contains("Fremd-RG") OrElse r.Cells("LeistungsBez").Value.Contains("RMC-RG"), True, False)
End If End If
'Vorzeichen einstellen. 'Vorzeichen einstellen.
If (r.Cells("Preis").Value < 0) Then If (r.Cells("Preis").Value < 0) Then
curBGebBetrag = 0 - curBGebBetrag 'Vorzeichen von Plus in Minus ändern. curBGebBetrag = 0 - curBGebBetrag 'Vorzeichen von Plus in Minus ändern.
@@ -2688,7 +2709,7 @@ Public Class usrCntlFaktAbrechnung
Dim preisInital As Double = 0 Dim preisInital As Double = 0
If Not IsDBNull(r.Cells("Preis").Value) Then If Not IsDBNull(r.Cells("Preis").Value) Then
preisInital = curBGebBetrag preisInital = curBGebBetrag '* IIf(RECHNUNG.Vorzeichen = "-", -1, 1)
End If End If
'Falls schon vorhanden... 'Falls schon vorhanden...
@@ -2704,8 +2725,8 @@ Public Class usrCntlFaktAbrechnung
preisInital = preisInital / 2 preisInital = preisInital / 2
row.Cells("Preis").Value = preisInital row.Cells("Preis").Value = preisInital
Exit For Exit For
ElseIf preisInital <> curBGebBetrag * 2 AndAlso summeRMCBearb <> preisInital AndAlso (minBetragRMCUsed OrElse isRMC OrElse isFREMD) AndAlso summeRMCBearb > curBGebMinBetrag Then 'wenn RMCPOS und Summe der berechneten Bearb > Mindestbetrag --> berechnetBearb verrechnet! ElseIf preisInital <> curBGebBetrag * 2 AndAlso (summeRMCBearb + summeFremdBearb) <> preisInital AndAlso (minBetragRMCUsed OrElse isRMC OrElse isFREMD) AndAlso (summeRMCBearb + summeFremdBearb) > curBGebMinBetrag Then 'wenn RMCPOS und Summe der berechneten Bearb > Mindestbetrag --> berechnetBearb verrechnet!
preisInital = summeRMCBearb preisInital = (summeRMCBearb + summeFremdBearb) * IIf(RECHNUNG.Vorzeichen = "-", -1, 1)
row.Cells("Preis").Value = preisInital row.Cells("Preis").Value = preisInital
Exit For Exit For
Else Else
@@ -2714,146 +2735,61 @@ Public Class usrCntlFaktAbrechnung
End If End If
End If End If
Next Next
End If
'hier wird der Betrag der BearbeitungsPOS NEU berechnet!
Dim curBearbPreis As Double = 0
Else
If changed Then If changed Then
'Dim bearbPreisNew As Double = 0
'If FremdUndRMC Then 'beides
' If isRMC Then
' If Math.Abs(preisInital) <> summeRMCBearb OrElse sumOffertRMC <> summeRMCBearb Then
' bearbPreisNew += summeRMCBearb
' ' End If
' ElseIf isFREMD Then
' If Math.Abs(preisInital) <> summeFremdBearb OrElse sumOffertFremd <> summeFremdBearb Then
' bearbPreisNew += summeFremdBearb
' End If
' End If
' End If
'ElseIf isRMC Then 'nur RMC
' If Math.Abs(preisInital) <> summeRMCBearb OrElse sumOffertFremd <> summeFremdBearb Then
' bearbPreisNew += summeRMCBearb
' End If
'ElseIf isFREMD Then 'nur Fremd
' If Math.Abs(preisInital) <> summeFremdBearb OrElse sumOffertRMC <> summeRMCBearb Then
' bearbPreisNew += summeFremdBearb
' End If
'End If
If (sumOffertRMC + sumOffertFremd) * IIf(RECHNUNG.Vorzeichen = "-", -1, 1) <> POS.Preis Then
For Each row As DataGridViewRow In dgvOfferteDetailsUebersicht.Rows For Each row As DataGridViewRow In dgvOfferteDetailsUebersicht.Rows
If row.Cells("LeistungsNr").Value = BGebLeistungsNr And row.Cells("BerechnungsartNr").Value = 9 AndAlso row.Cells("Anzahl").Value = 1 Then If row.Cells("LeistungsNr").Value = BGebLeistungsNr And row.Cells("BerechnungsartNr").Value = 9 Then
If row.Cells("Preis").Value <> (sumOffertRMC + sumOffertFremd) * IIf(RECHNUNG.Vorzeichen = "-", -1, 1) Then
If IsDBNull(row.Cells("Preis").Value) Then row.Cells("Preis").Value = preisInital row.Cells("Preis").Value = (sumOffertRMC + sumOffertFremd) * IIf(RECHNUNG.Vorzeichen = "-", -1, 1)
POS.Anzahl = 1
curBearbPreis += row.Cells("Preis").Value initSteuerbetraege(RECHNUNG, POS)
POSChanged = True
Exit For
If FremdUndRMC Then
'beide POS sind enthalten
If curBearbPreis = curBGebBetrag * 2 AndAlso minBetragRMCUsed Then 'wenn RMCPOS und MIND-BERTAG 2x verrechnet -> nur 1x berechnen
If curBearbPreis <> row.Cells("Preis").Value Then row.Cells("Preis").Value = curBGebBetrag / 2
ElseIf curBearbPreis <> curBGebBetrag * 2 AndAlso summeRMCBearb <> curBearbPreis AndAlso (minBetragRMCUsed OrElse isRMC OrElse isFREMD) AndAlso summeRMCBearb > curBGebMinBetrag Then 'wenn RMCPOS und Summe der berechneten Bearb > Mindestbetrag --> berechnetBearb verrechnet!
If summeRMCBearb > row.Cells("Preis").Value Then
If Math.Abs(row.Cells("Preis").Value - summeRMCBearb) > 0.5 Then 'Rundungsdifferenzen ignorieren (weil sonst Deadloop)
row.Cells("Preis").Value = summeRMCBearb
End If
End If End If
End If End If
Else
If minBetragRMCUsed Then
If curBearbPreis > curBGebBetrag AndAlso summeRMCBearb > 0 Then
If curBearbPreis <> summeRMCBearb Then row.Cells("Preis").Value = summeRMCBearb
Else
If curBearbPreis <> curBGebMinBetrag Then row.Cells("Preis").Value = curBGebMinBetrag
End If
Else
If curBearbPreis > curBGebBetrag AndAlso summeRMCBearb > 0 Then
If curBearbPreis <> summeRMCBearb Then row.Cells("Preis").Value = summeRMCBearb
End If
End If
End If
'If curBearbPreis <> curBGebBetrag * 2 AndAlso curBearbPreis <> summeRMCBearb AndAlso (minBetragRMCUsed OrElse isRMC) Then
' If summeRMCBearb > curBGebMinBetrag AndAlso summeRMCBearb <> 0 Then
' If curBearbPreis <> summeRMCBearb Then row.Cells("Preis").Value = summeRMCBearb
' ElseIf curBGebErrBetrag = summeRMCBearb Then
' If Not FremdUndRMC Then 'dann ist das die die erste POS und es gibt nur 1 hier setzen, sonder überspringen!! '!!!!!!!!! außer beide POS fallen unter die Mindestgrenze!!!
' If curBearbPreis <> curBGebMinBetrag Then row.Cells("Preis").Value = curBGebMinBetrag
' End If
' ElseIf curBGebErrBetrag <> summeRMCBearb And FremdUndRMC Then 'dann ist das die NICHT die erste POS, hier setzen
' If curBearbPreis <> curBGebMinBetrag Then row.Cells("Preis").Value = curBGebMinBetrag
' End If
'ElseIf curBearbPreis = curBGebBetrag * 2 AndAlso minBetragRMCUsed Then
' If curBearbPreis <> curBGebBetrag Then row.Cells("Preis").Value = curBGebBetrag
'ElseIf Not isRMC AndAlso curBearbPreis <> curBGebBetrag Then
' If curBearbPreis <> curBGebBetrag Then row.Cells("Preis").Value = curBGebBetrag
'End If
'If row.Cells("Preis").Value = curBGebBetrag * 2 AndAlso minBetragRMCUsed Then 'wenn RMCPOS und MIND-BERTAG 2x verrechnet -> nur 1x berechnen
' row.Cells("Preis").Value = row.Cells("Preis").Value / 2
'ElseIf row.Cells("Preis").Value <> curBGebBetrag * 2 AndAlso summeRMCBearb <> row.Cells("Preis").Value AndAlso (minBetragRMCUsed OrElse isRMC) AndAlso summeRMCBearb > curBGebMinBetrag Then 'wenn RMCPOS und Summe der berechneten Bearb > Mindestbetrag --> berechnetBearb verrechnet!
' row.Cells("Preis").Value = summeRMCBearb
'End If
End If
Next Next
End If
End If End If
'POS.Preis += curBGebBetrag
'If POS.Preis = curBGebBetrag * 2 AndAlso minBetragRMCUsed Then 'wenn RMCPOS und MIND-BERTAG 2x verrechnet -> nur 1x berechnen End If
' POS.Preis = POS.Preis / 2
'ElseIf POS.Preis <> curBGebBetrag * 2 AndAlso summeRMCBearb <> POS.Preis AndAlso (minBetragRMCUsed OrElse isRMC) AndAlso summeRMCBearb > curBGebMinBetrag Then 'wenn RMCPOS und Summe der berechneten Bearb > Mindestbetrag --> berechnetBearb verrechnet!
' POS.Preis = summeRMCBearb
'End If
'If POS.Steuerpflichtig Then
' POS.SteuerpflichtigerBetrag += curBGebBetrag
' If POS.SteuerpflichtigerBetrag = curBGebBetrag * 2 AndAlso minBetragRMCUsed Then 'wenn RMCPOS und MIND-BERTAG 2x verrechnet -> nur 1x berechnen
' POS.SteuerpflichtigerBetrag = POS.SteuerpflichtigerBetrag / 2
' ElseIf POS.SteuerpflichtigerBetrag <> curBGebBetrag * 2 AndAlso summeRMCBearb <> POS.SteuerpflichtigerBetrag AndAlso (minBetragRMCUsed OrElse isRMC) AndAlso summeRMCBearb > curBGebMinBetrag Then 'wenn RMCPOS und Summe der berechneten Bearb > Mindestbetrag --> berechnetBearb verrechnet!
' POS.SteuerpflichtigerBetrag = summeRMCBearb
' End If
'Else
' POS.SteuerfreierBetrag += curBGebBetrag
' If POS.SteuerfreierBetrag = curBGebBetrag * 2 AndAlso minBetragRMCUsed Then 'wenn RMCPOS und MIND-BERTAG 2x verrechnet -> nur 1x berechnen
' POS.SteuerfreierBetrag = POS.SteuerfreierBetrag / 2
' ElseIf POS.SteuerpflichtigerBetrag <> curBGebBetrag * 2 AndAlso summeRMCBearb <> POS.SteuerpflichtigerBetrag AndAlso (minBetragRMCUsed OrElse isRMC) AndAlso summeRMCBearb > curBGebMinBetrag Then 'wenn RMCPOS und Summe der berechneten Bearb > Mindestbetrag --> berechnetBearb verrechnet!
' POS.SteuerpflichtigerBetrag = summeRMCBearb
' End If
'End If
End If End If
Next Next
'Catch ex As Exception
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
'End Try
' Return False
'End Function
End If End If
End If End If
@@ -4809,7 +4745,7 @@ Nächste_Textzeile_lesen:
End Function End Function
Private Sub setMWSTABRfromSPEDinPOS(r As DataGridViewRow, LandNr As String, LandBez As String, ByRef summeRMC As Double, ByRef FremdUndRMC As Boolean, Optional antrag As cUSTVAntrag = Nothing, Optional isVZ As Boolean = False, Optional changed As Boolean = False) Private Sub setMWSTABRfromSPEDinPOS(r As DataGridViewRow, LandNr As String, LandBez As String, ByRef summeRMC As Double, ByRef summeFremd As Double, ByRef FremdUndRMC As Boolean, ByRef POSChanged As Boolean, Optional antrag As cUSTVAntrag = Nothing, Optional isVZ As Boolean = False, Optional changed As Boolean = False, Optional sumOffertRMC As Double = 0, Optional BearbRMC As Double = 0, Optional sumOffertFremd As Double = 0, Optional BearbFremd As Double = 0)
If SPEDBUCH IsNot Nothing AndAlso (SPEDBUCH.Abfertigungsart = 114 Or SPEDBUCH.Abfertigungsart = 115 Or SPEDBUCH.Abfertigungsart = 10) Then If SPEDBUCH IsNot Nothing AndAlso (SPEDBUCH.Abfertigungsart = 114 Or SPEDBUCH.Abfertigungsart = 115 Or SPEDBUCH.Abfertigungsart = 10) Then
@@ -4836,9 +4772,9 @@ Nächste_Textzeile_lesen:
Dim kdNr = IIf(RECHNUNG.RechnungsKundenNr > 0, RECHNUNG.RechnungsKundenNr, kdFirmaRechnungAn.KdNr) Dim kdNr = IIf(RECHNUNG.RechnungsKundenNr > 0, RECHNUNG.RechnungsKundenNr, kdFirmaRechnungAn.KdNr)
Dim isRMCKunde = IIf(kdNr = 150000 AndAlso (antrag.UStVAn_AntragArt = "MWST" Or antrag.UStVAn_AntragArt = "MOEST"), True, False) Dim isRMCKunde = IIf(kdNr = 150000 AndAlso (antrag.UStVAn_AntragArt = "MWST" Or antrag.UStVAn_AntragArt = "MOEST"), True, False)
Dim sumRMC As Double = 0 Dim sumRMCAntrag As Double = 0
Dim sumFremdBeleg As Double = 0 Dim sumFremdAntrag As Double = 0
Dim sumBelegVZ As Double = 0 Dim sumVZAntrag As Double = 0
If antrag IsNot Nothing AndAlso LandBez <> "" AndAlso antrag.UStVAn_AntragArt <> "" Then If antrag IsNot Nothing AndAlso LandBez <> "" AndAlso antrag.UStVAn_AntragArt <> "" Then
@@ -4861,10 +4797,6 @@ Nächste_Textzeile_lesen:
Dim USTV_RO = antrag.UStVAn_AntragArt.ToString.ToLower.Replace("mwst", "rambursare tva") Dim USTV_RO = antrag.UStVAn_AntragArt.ToString.ToLower.Replace("mwst", "rambursare tva")
Dim MÖST_RO = antrag.UStVAn_AntragArt.ToString.ToLower.Replace("moest", "rambursare acciza") Dim MÖST_RO = antrag.UStVAn_AntragArt.ToString.ToLower.Replace("moest", "rambursare acciza")
If OFFERT_LAND = "FR" Then
'MsgBox("Test1")
End If
If OFFERT_LAND = LandISO2 AndAlso (OFFERT_LeistungsBez.ToString.ToLower.StartsWith(antrag.UStVAn_AntragArt.ToString.ToLower) Or If OFFERT_LAND = LandISO2 AndAlso (OFFERT_LeistungsBez.ToString.ToLower.StartsWith(antrag.UStVAn_AntragArt.ToString.ToLower) Or
OFFERT_LeistungsBez.ToString.ToLower.StartsWith(USTV_EN) Or OFFERT_LeistungsBez.ToString.ToLower.StartsWith(USTV_EN) Or
OFFERT_LeistungsBez.ToString.ToLower.StartsWith(MÖST_EN) Or OFFERT_LeistungsBez.ToString.ToLower.StartsWith(MÖST_EN) Or
@@ -4883,16 +4815,16 @@ Nächste_Textzeile_lesen:
If ANTR_POS.UStVPo_Leistender.ToString.ToUpper.StartsWith("RMC") Then If ANTR_POS.UStVPo_Leistender.ToString.ToUpper.StartsWith("RMC") Then
If isVZ Then If isVZ Then
If ANTR_POS.UStVPo_VZ AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ_RKID) Or ANTR_POS.UStVPo_VZ_RKID Is Nothing) Then sumRMC += ANTR_POS.UStVPo_USteuerbetragEUR If ANTR_POS.UStVPo_VZ AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ_RKID) Or ANTR_POS.UStVPo_VZ_RKID Is Nothing) Then sumRMCAntrag += ANTR_POS.UStVPo_USteuerbetragEUR
Else Else
If ANTR_POS.UStVPo_VZ_RKID Is Nothing AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ) OrElse Not ANTR_POS.UStVPo_VZ) Then sumRMC += ANTR_POS.UStVPo_USteuerbetragEUR If ANTR_POS.UStVPo_VZ_RKID Is Nothing AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ) OrElse Not ANTR_POS.UStVPo_VZ) Then sumRMCAntrag += ANTR_POS.UStVPo_USteuerbetragEUR
End If End If
Else Else
If isVZ Then If isVZ Then
If ANTR_POS.UStVPo_VZ AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ_RKID) Or ANTR_POS.UStVPo_VZ_RKID Is Nothing) Then sumFremdBeleg += ANTR_POS.UStVPo_USteuerbetragEUR If ANTR_POS.UStVPo_VZ AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ_RKID) Or ANTR_POS.UStVPo_VZ_RKID Is Nothing) Then sumFremdAntrag += ANTR_POS.UStVPo_USteuerbetragEUR
Else Else
If ANTR_POS.UStVPo_VZ_RKID Is Nothing AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ) OrElse Not ANTR_POS.UStVPo_VZ) Then sumFremdBeleg += ANTR_POS.UStVPo_USteuerbetragEUR If ANTR_POS.UStVPo_VZ_RKID Is Nothing AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ) OrElse Not ANTR_POS.UStVPo_VZ) Then sumFremdAntrag += ANTR_POS.UStVPo_USteuerbetragEUR
End If End If
End If End If
@@ -4920,7 +4852,7 @@ Nächste_Textzeile_lesen:
For Each ANTR_POS As cUStVPositionen In antrag.POSITIONEN For Each ANTR_POS As cUStVPositionen In antrag.POSITIONEN
If ANTR_POS.UStVPo_VZ AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ_RKID) Or ANTR_POS.UStVPo_VZ_RKID Is Nothing) Then sumBelegVZ += ANTR_POS.UStVPo_USteuerbetragEUR If ANTR_POS.UStVPo_VZ AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ_RKID) Or ANTR_POS.UStVPo_VZ_RKID Is Nothing) Then sumVZAntrag += ANTR_POS.UStVPo_USteuerbetragEUR
Next Next
@@ -4931,7 +4863,7 @@ Nächste_Textzeile_lesen:
For Each ANTR_POS As cUStVPositionen In antrag.POSITIONEN For Each ANTR_POS As cUStVPositionen In antrag.POSITIONEN
If ANTR_POS.UStVPo_VZ_RKID Is Nothing AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ) OrElse Not ANTR_POS.UStVPo_VZ) Then sumFremdBeleg += ANTR_POS.UStVPo_USteuerbetragEUR If ANTR_POS.UStVPo_VZ_RKID Is Nothing AndAlso (IsDBNull(ANTR_POS.UStVPo_VZ) OrElse Not ANTR_POS.UStVPo_VZ) Then sumFremdAntrag += ANTR_POS.UStVPo_USteuerbetragEUR
Next Next
@@ -4956,15 +4888,15 @@ mwst:
If IsDBNull(r.Cells("Preis").Value) OrElse r.Cells("Preis").Value = 0 Then If IsDBNull(r.Cells("Preis").Value) OrElse r.Cells("Preis").Value = 0 Then
If isRMCKunde Then If isRMCKunde Then
If OFFERT_RMC AndAlso sumRMC <> 0 Then If OFFERT_RMC AndAlso sumRMCAntrag <> 0 Then
r.Cells("Preis").Value = sumRMC '* -1 r.Cells("Preis").Value = sumRMCAntrag
ElseIf OFFERT_FREMD AndAlso sumFremdBeleg <> 0 Then ElseIf OFFERT_FREMD AndAlso sumFremdAntrag <> 0 Then
r.Cells("Preis").Value = sumFremdBeleg '* -1 r.Cells("Preis").Value = sumFremdAntrag
End If End If
Else Else
If sumBelegVZ <> 0 Then If sumVZAntrag <> 0 Then
r.Cells("Preis").Value = sumBelegVZ '* -1 r.Cells("Preis").Value = sumVZAntrag
Else Else
Dim GesamtUSteuerEUR As Double = SQL.DLookup("isnull(sum(UStVPo_USteuerbetragEUR),0)", "tblUStVPositionen", "UStVAn_ID='" & antrag.UStVAn_ID & "'", "FMZOLL", "0") Dim GesamtUSteuerEUR As Double = SQL.DLookup("isnull(sum(UStVPo_USteuerbetragEUR),0)", "tblUStVPositionen", "UStVAn_ID='" & antrag.UStVAn_ID & "'", "FMZOLL", "0")
@@ -4972,7 +4904,7 @@ mwst:
Dim DiffernezbetragEUR As Double = GesamtUSteuerEUR - GesamtErstattungEUR Dim DiffernezbetragEUR As Double = GesamtUSteuerEUR - GesamtErstattungEUR
If DiffernezbetragEUR <> 0 Then If DiffernezbetragEUR <> 0 Then
r.Cells("Preis").Value = DiffernezbetragEUR '* -1 r.Cells("Preis").Value = DiffernezbetragEUR
End If End If
End If End If
@@ -4991,7 +4923,7 @@ mwst:
If OffertNr = 15 Or OffertNr = 14 Or OffertNr = 31 Then If OffertNr = 15 Or OffertNr = 14 Or OffertNr = 31 Then
If Not IsDBNull(r.Cells("Preis").Value) Then If Not IsDBNull(r.Cells("Preis").Value) Then
Dim OFFERTE As New VERAG_PROG_ALLGEMEIN.cOfferte(IIf(RECHNUNG.RechnungsKundenNr > 0, RECHNUNG.RechnungsKundenNr, kdFirmaRechnungAn.KdNr), OffertNr, True) Dim OFFERTE As New VERAG_PROG_ALLGEMEIN.cOfferte(IIf(RECHNUNG.RechnungsKundenNr > 0, RECHNUNG.RechnungsKundenNr, kdFirmaRechnungAn.KdNr), OffertNr, True)
Call prBearbGeb_NEW(r, OFFERTE, RECHNUNG, r.Cells("BGebLeistungsNr").Value, r.Cells("BGebProzent").Value, IIf(Not IsDBNull(r.Cells("BGebMinBetrag").Value), r.Cells("BGebMinBetrag").Value, 0), r.Cells("Preis").Value * If(RECHNUNG.Vorzeichen = "-", -1, 1), summeRMC, OFFERT_RMC, OFFERT_FREMD, FremdUndRMC, changed) Call prBearbGeb_NEW(r, OFFERTE, RECHNUNG, r.Cells("BGebLeistungsNr").Value, r.Cells("BGebProzent").Value, IIf(Not IsDBNull(r.Cells("BGebMinBetrag").Value), r.Cells("BGebMinBetrag").Value, 0), r.Cells("Preis").Value * If(RECHNUNG.Vorzeichen = "-", -1, 1), summeRMC, summeFremd, OFFERT_RMC, OFFERT_FREMD, FremdUndRMC, changed, sumRMCAntrag, sumOffertRMC, sumFremdAntrag, sumOffertFremd, sumVZAntrag, POSChanged)
End If End If
End If End If