Fremdrechnungen

This commit is contained in:
2025-03-12 16:47:15 +01:00
parent eb42f14278
commit 3e4167775b
3 changed files with 49 additions and 8 deletions

View File

@@ -76,7 +76,7 @@ Public Class usrcntlFremdrechnungen
KUNDE = kundenSQL.getKundeByKdNr(kdNr)
If KUNDE IsNot Nothing Then
dtkeineMWST = (New SQL).loadDgvBySql("select Land, Erstattungsland from tblKeineMWSTErstattung", "FMZOLL")
dtkeineMWST = (New SQL).loadDgvBySql("select Land, Erstattungsland, Lieferant from tblKeineMWSTErstattung", "FMZOLL")
dtKundeMWST = (New SQL).loadDgvBySql("select LandKz from tblKundenMWST where KdNr = " & KUNDE.KundenNr, "FMZOLL")
End If
@@ -355,7 +355,7 @@ Public Class usrcntlFremdrechnungen
'2. wenn die Rechnung die Summe NULL aufweist
Select Case aktLieferant
Case "UTA" : If Not alle Then SQLWhere &= " AND Gesamtbetrag_Brutto_in_Darstellwährung <> 0" 'UTA
Case "UTA" : If Not alle Then SQLWhere &= " AND Gesamtbetrag_Brutto_in_Darstellwährung <> 0 AND Art = 'RE'" 'UTA bei UTA auch EPN ausblenden!
Case "PLOSE" : If Not alle Then SQLWhere &= " AND plInv_Bruttobetrag <> 0" 'PLOSE
Case "VERAG" : If Not alle Then SQLWhere &= " AND (tblTrdinInvoice.SteuerpflichtigerBetragLokal + tblTrdinInvoice.SteuerfreierBetragLokal) <> 0" 'VERAG
Case "MSE" : If Not alle Then SQLWhere &= " AND total_amount_euro <> 0" 'MSE
@@ -376,12 +376,13 @@ Public Class usrcntlFremdrechnungen
'3. Rechnungen der Länder in denen der Kunde keine MWST erstattet bekommt
If land <> "" AndAlso dtkeineMWST.Rows.Count > 0 Then
Dim dtkeineMWST_ohneContraint As DataTable = dtkeineMWST.Select("Lieferant = ''").CopyToDataTable
Dim counter = 0
Dim landBez As String = ""
For Each row As DataRow In dtkeineMWST.Rows
For Each row As DataRow In dtkeineMWST_ohneContraint.Rows
landBez = "'" & row.Item("Erstattungsland") & "'"
counter = counter + 1
If (dtkeineMWST.Rows.Count <> 0 And counter <> dtkeineMWST.Rows.Count) Then landBez &= ","
If (dtkeineMWST_ohneContraint.Rows.Count <> 0 And counter <> dtkeineMWST_ohneContraint.Rows.Count) Then landBez &= ","
Next
SQLWhere &= " AND " & land & " not in (" & landBez & ")"
End If
@@ -447,12 +448,13 @@ Public Class usrcntlFremdrechnungen
'3. Rechnungen der Länder in denen der Kunde keine MWST erstattet bekommt
If land <> "" AndAlso dtkeineMWST.Rows.Count > 0 Then
Dim dtkeineMWST_IDS As DataTable = dtkeineMWST.Select("Lieferant = 'IDS'").CopyToDataTable
Dim counter = 0
Dim landBez As String = ""
For Each row As DataRow In dtkeineMWST.Rows
For Each row As DataRow In dtkeineMWST_IDS.Rows
landBez = "'" & row.Item("Erstattungsland") & "'"
counter = counter + 1
If (dtkeineMWST.Rows.Count <> 0 And counter <> dtkeineMWST.Rows.Count) Then landBez &= ","
If (dtkeineMWST_IDS.Rows.Count <> 0 And counter <> dtkeineMWST_IDS.Rows.Count) Then landBez &= ","
Next
SQLWhere &= " AND " & land & " not in (" & landBez & ")"
End If
@@ -687,7 +689,7 @@ Public Class usrcntlFremdrechnungen
TextHTMLtable &= "<td><b>" & r.Item("Rechnungsdatum") & "</b></td>"
TextHTMLtable &= "</tr>"
Dim daId = r.Item("daId")
Dim daId As Integer = IIf(IsDBNull(r.Item("daId")), -1, r.Item("daId"))
If daId > 0 Then
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER(daId)
pdflist.Add(DS.GET_TOP1_PATH())
@@ -704,7 +706,7 @@ Public Class usrcntlFremdrechnungen
TextHTMLtable &= "<td><b>" & row.Cells("Rechnungsdatum").Value & "</b></td>"
TextHTMLtable &= "</tr>"
Dim daId = row.Cells("daId").Value
Dim daId As Integer = IIf(IsDBNull(row.Cells("daId").Value), -1, row.Cells("daId").Value)
If daId > 0 Then
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER(daId)
pdflist.Add(DS.GET_TOP1_PATH())