Offerten, Fremdrechnungen
This commit is contained in:
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.3.7.2")>
|
||||
<Assembly: AssemblyFileVersion("1.3.7.2")>
|
||||
<Assembly: AssemblyVersion("1.3.7.3")>
|
||||
<Assembly: AssemblyFileVersion("1.3.7.3")>
|
||||
|
||||
@@ -820,19 +820,13 @@ Public Class usrCntlOfferte
|
||||
If True Then
|
||||
|
||||
|
||||
|
||||
|
||||
Dim KD As New VERAG_PROG_ALLGEMEIN.cKunde(kdNr)
|
||||
Dim ADR As New VERAG_PROG_ALLGEMEIN.cAdressen(kdNr)
|
||||
Dim FIRMA_TMP = VERAG_PROG_ALLGEMEIN.cAllgemein.getFirmaFromFiliale(KD.FilialenNr)
|
||||
|
||||
If dgvOfferteDetails.Rows.Count = 0 Then Exit Sub
|
||||
|
||||
Dim sqlKostenkalk = " Select OffertenNr, isnull(LeistungsNr,'') as LeistungsNr,isnull(LeistungsBez,'' ) as LeistungsBez,isnull(Preis,'') as Preis,isnull([Geändert am],[Eingegeben am]) as Datum
|
||||
FROM [VERAG].[dbo].[Offertenpositionen] where KundenNr = " & kdNr & " and OffertenNr in (38, 1) and LeistungsNr in (340, 324, 348, 440)
|
||||
order by Preis desc"
|
||||
|
||||
|
||||
Dim dtKostenkalk As DataTable = (New SQL).loadDgvBySql(sqlKostenkalk, "FMZOLL")
|
||||
Dim dtKostenkalk As DataTable = cProgramFunctions.dgridViewTods(dgvOfferteDetails)
|
||||
|
||||
If dtKostenkalk.Rows.Count < 1 Then
|
||||
MsgBox("keine Daten!")
|
||||
@@ -895,11 +889,16 @@ Public Class usrCntlOfferte
|
||||
|
||||
Dim currentRow As Integer = 13
|
||||
|
||||
Dim DatumDerZollabf As String = SQL.getValueTxtBySql("select top(1) isnull([Geändert am],[Eingegeben am]) as Datum FROM [VERAG].[dbo].[Offertenpositionen] where KundenNr = " & kdNr & " and OffertenNr in (38, 1) and LeistungsNr in (340, 324, 348, 440) order by Preis desc", "FMZOLL")
|
||||
Dim dtkeineMdtKostenkalk_mitPreise As DataTable = dtKostenkalk.Select("Preis <> ''", "Preis desc").CopyToDataTable
|
||||
|
||||
For Each row In dtkeineMdtKostenkalk_mitPreise.Rows
|
||||
|
||||
For Each row In dtKostenkalk.Rows
|
||||
Blatt.Range("A" & currentRow).Value = row("LeistungsBez")
|
||||
Blatt.Range("B" & currentRow).Value = row("Preis")
|
||||
Blatt.Range("B" & currentRow).Value = CDbl(row("Preis"))
|
||||
|
||||
Dim DatumDerZollabf As String = dtkeineMdtKostenkalk_mitPreise.Rows(0).Item("Geändert am")
|
||||
|
||||
If DatumDerZollabf = "" Then DatumDerZollabf = dtkeineMdtKostenkalk_mitPreise.Rows(0).Item("Eingegeben am")
|
||||
|
||||
If IsDate(DatumDerZollabf) Then
|
||||
|
||||
|
||||
@@ -217,9 +217,9 @@ Public Class usrcntlFremdrechnungen
|
||||
|
||||
'UTA
|
||||
Case "UTA" : SQL_STR = "SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") &
|
||||
" [Rechnungsdatum],[Rechnungsnummer_pro_Lieferland] as Rechnungsnummer,Kundennummer,SUM(Gesamtbetrag_Brutto_in_Darstellwährung) as Bruttobetrag,SUM(Gesamtbetrag_Netto_in_Darstellwährung) as Nettobetrag, SUM(Gesamtbetrag_Umsatzsteuer_in_Darstellwährung) as MWSt,[daId],[Lieferland_ISO2] as Land, 'RE' as Art, cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM [VERAG].[dbo].[tblUTAImportNew] inner join adressen on Kundennummer = UTAKundenNr where 1 = 1 " & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " AND [Rechnungsdatum] " & setSQLWhere(SDLNrTmp, "Land") & " group by [Rechnungsnummer_pro_Lieferland],[Rechnungsdatum],Kundennummer,[daId],[Lieferland_ISO2]"
|
||||
" [Rechnungsdatum],[Rechnungsnummer_pro_Lieferland] as Rechnungsnummer,Kundennummer,SUM(Gesamtbetrag_Brutto_in_Darstellwährung) as Bruttobetrag,SUM(Gesamtbetrag_Netto_in_Darstellwährung) as Nettobetrag, SUM(Gesamtbetrag_Umsatzsteuer_in_Darstellwährung) as MWSt,[daId],[Lieferland_ISO2] as Land, 'RE' as Art, cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM [VERAG].[dbo].[tblUTAImportNew] inner join adressen on Kundennummer = UTAKundenNr where 1 = 1 " & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " AND [Rechnungsdatum] " & setSQLWhere(SDLNrTmp, "Lieferland_ISO2") & " group by [Rechnungsnummer_pro_Lieferland],[Rechnungsdatum],Kundennummer,[daId],[Lieferland_ISO2]"
|
||||
|
||||
SQL_STR &= " UNION ALL SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") & " [Datum], [RechnungsNr],[KundenNr],0,0,0,[daId],'',[DocumentTyp], cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM [VERAG].[dbo].[tblUTADocuments] inner join adressen on KundenNr = UTAKundenNr where 1 = 1 " & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " and [Datum] " & setSQLWhere(SDLNrTmp, "") & " order by Rechnungsdatum desc"
|
||||
SQL_STR &= " UNION ALL SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") & " [Datum], [RechnungsNr],[KundenNr],0,0,0,[daId],'',[DocumentTyp], cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM [VERAG].[dbo].[tblUTADocuments] inner join adressen on KundenNr = UTAKundenNr where 1 = 1 " & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " and [Datum] " & setSQLWhere("_", "") & " order by Rechnungsdatum desc"
|
||||
|
||||
'PLOSE
|
||||
Case "PLOSE" : SQL_STR = "SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") &
|
||||
@@ -239,36 +239,36 @@ Public Class usrcntlFremdrechnungen
|
||||
Case "ALLE" : Dim anzahl As Integer = anzahlTop / 6 : SQL_STR = " select * from (SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") &
|
||||
"
|
||||
--IDS
|
||||
'IDS' as Lieferant,invoice_id, [YearMonthDay] as Rechnungsdatum,[Invoicenumber] as Rechnungsnummer,CustomerCode as Kundennummer,[AmminclVAT] as Bruttobetrag,[TotalNetAmount] as Nettobetrag,[VATAmount] as MWSt,'' as Land, 'RE' as Art,[daId], cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM tblIDSInvoicesNew WHERE [CustomerCode] = (SELECT TOP 1 [CustomerCode] FROM [VERAG].[dbo].[tbl_IDS_Kunden] WHERE 1 = 1 " & IIf(kdNr > 0, " AND [KdNrVERAG]=" & kdNr, "") & " ORDER BY Zeitstempel DESC) and [YearMonthDay] " & setSQLWhere(SDLNrTmp, "") & " order by [YearMonthDay], [Invoicenumber]
|
||||
'IDS' as Lieferant,invoice_id, [YearMonthDay] as Rechnungsdatum,[Invoicenumber] as Rechnungsnummer,CustomerCode as Kundennummer,[AmminclVAT] as Bruttobetrag,[TotalNetAmount] as Nettobetrag,[VATAmount] as MWSt,'' as Land, 'RE' as Art,[daId], cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM tblIDSInvoicesNew WHERE [CustomerCode] = (SELECT TOP 1 [CustomerCode] FROM [VERAG].[dbo].[tbl_IDS_Kunden] WHERE 1 = 1 " & IIf(kdNr > 0, " AND [KdNrVERAG]=" & kdNr, "") & " ORDER BY Zeitstempel DESC) and [YearMonthDay] " & setSQLWhere("IDS", "") & " order by [YearMonthDay], [Invoicenumber]
|
||||
|
||||
UNION ALL
|
||||
|
||||
|
||||
--MSE
|
||||
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'MSE' as Lieferant,-1 as invoice_id, [invoice_date] as Rechnungsdatum, cast([invoice_id] as nvarchar) as Rechnungsnummer,[customer_number] as Kundennummer, [total_amount_euro] as Bruttobetrag ,(total_amount_euro - [total_vat_amount_euro]) as Nettobetrag ,[total_vat_amount_euro] as MWST,[country] as Land,'RE' as Art,daId, cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM tblMSEInvoices where customer_number = (select top 1 customer_id from tblMSECustomers where 1 = 1 " & IIf(kdNr > 0, " AND [partner_customer_number]=" & kdNr, "") & " and [invoice_date] " & setSQLWhere(SDLNrTmp, "country") & " ) order by invoice_date, invoice_id
|
||||
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'MSE' as Lieferant,-1 as invoice_id, [invoice_date] as Rechnungsdatum, cast([invoice_id] as nvarchar) as Rechnungsnummer,[customer_number] as Kundennummer, [total_amount_euro] as Bruttobetrag ,(total_amount_euro - [total_vat_amount_euro]) as Nettobetrag ,[total_vat_amount_euro] as MWST,[country] as Land,'RE' as Art,daId, cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM tblMSEInvoices where customer_number = (select top 1 customer_id from tblMSECustomers where 1 = 1 " & IIf(kdNr > 0, " AND [partner_customer_number]=" & kdNr, "") & " and [invoice_date] " & setSQLWhere("MSE", "country") & " ) order by invoice_date, invoice_id
|
||||
|
||||
UNION ALL
|
||||
|
||||
--UTA
|
||||
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'UTA' as Lieferant,-1 as invoice_id, [Rechnungsdatum],STR([Rechnungsnummer_pro_Lieferland]) as Rechnungsnummer,Kundennummer,SUM(Gesamtbetrag_Brutto_in_Darstellwährung) as Bruttobetrag,SUM(Gesamtbetrag_Netto_in_Darstellwährung) as Nettobetrag, SUM(Gesamtbetrag_Umsatzsteuer_in_Darstellwährung) as MWSt,[Lieferland_ISO2] as Land, 'RE' as Art,[daId], cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM [VERAG].[dbo].[tblUTAImportNew] inner join adressen on Kundennummer = UTAKundenNr where 1 = 1 " & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " and [Rechnungsdatum] " & setSQLWhere(SDLNrTmp, "Lieferland_ISO2") & " group by [Rechnungsnummer_pro_Lieferland],[Rechnungsdatum],Kundennummer,[daId],[Lieferland_ISO2] UNION ALL SELECT 'UTA',-1, [Datum], cast([RechnungsNr] as nvarchar) ,[KundenNr],0,0,0,'',[DocumentTyp],[daId], cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM [VERAG].[dbo].[tblUTADocuments] inner join adressen on KundenNr = UTAKundenNr where AdressenNr = " & kdNr & " AND Datum " & setSQLWhere(SDLNrTmp, "") & " --order by Rechnungsnummer desc
|
||||
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'UTA' as Lieferant,-1 as invoice_id, [Rechnungsdatum],STR([Rechnungsnummer_pro_Lieferland]) as Rechnungsnummer,Kundennummer,SUM(Gesamtbetrag_Brutto_in_Darstellwährung) as Bruttobetrag,SUM(Gesamtbetrag_Netto_in_Darstellwährung) as Nettobetrag, SUM(Gesamtbetrag_Umsatzsteuer_in_Darstellwährung) as MWSt,[Lieferland_ISO2] as Land, 'RE' as Art,[daId], cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM [VERAG].[dbo].[tblUTAImportNew] inner join adressen on Kundennummer = UTAKundenNr where 1 = 1 " & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " and [Rechnungsdatum] " & setSQLWhere("UTA", "Lieferland_ISO2") & " group by [Rechnungsnummer_pro_Lieferland],[Rechnungsdatum],Kundennummer,[daId],[Lieferland_ISO2] UNION ALL SELECT 'UTA',-1, [Datum], cast([RechnungsNr] as nvarchar) ,[KundenNr],0,0,0,'',[DocumentTyp],[daId], cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM [VERAG].[dbo].[tblUTADocuments] inner join adressen on KundenNr = UTAKundenNr where AdressenNr = " & kdNr & " AND Datum " & setSQLWhere("UTA_", "") & " --order by Rechnungsnummer desc
|
||||
|
||||
UNION ALL
|
||||
--VERAG
|
||||
|
||||
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'VERAG' as Lieferant,-1 as invoice_id, tblTrdinInvoice.Rechnungsdatum, cast(tblTrdinInvoice.Rechnungsnummer as nvarchar) as Rechnungsnummer ,tblTrdinInvoice.KundenNrZentrale as Kundennummer, tblTrdinInvoice.SteuerpflichtigerBetragLokal + tblTrdinInvoice.SteuerfreierBetragLokal as Bruttobetrag ,tblTrdinInvoice.SteuerpflichtigerBetragLokal + tblTrdinInvoice.SteuerfreierBetragLokal - tblTrdinInvoice.SteuerbetragLokal as Nettobetrag ,tblTrdinInvoice.SteuerbetragLokal as MWST, 'AT' as Land, 'RE' as Art, 1 as daId, cast(1 as bit) PDFvorhanden FROM tblTrdinInvoice WHERE 1 = 1 " & IIf(kdNr > 0, " AND tblTrdinInvoice.RechnungsKundenNr=" & kdNr, "") & " and tblTrdinInvoice.Rechnungsdatum " & setSQLWhere(SDLNrTmp, "'AT'") & " AND tblTrdinInvoice.FilialenNr = 4814 ORDER BY tblTrdinInvoice.Rechnungsdatum, tblTrdinInvoice.Rechnungsnummer
|
||||
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'VERAG' as Lieferant,-1 as invoice_id, tblTrdinInvoice.Rechnungsdatum, cast(tblTrdinInvoice.Rechnungsnummer as nvarchar) as Rechnungsnummer ,tblTrdinInvoice.KundenNrZentrale as Kundennummer, tblTrdinInvoice.SteuerpflichtigerBetragLokal + tblTrdinInvoice.SteuerfreierBetragLokal as Bruttobetrag ,tblTrdinInvoice.SteuerpflichtigerBetragLokal + tblTrdinInvoice.SteuerfreierBetragLokal - tblTrdinInvoice.SteuerbetragLokal as Nettobetrag ,tblTrdinInvoice.SteuerbetragLokal as MWST, 'AT' as Land, 'RE' as Art, 1 as daId, cast(1 as bit) PDFvorhanden FROM tblTrdinInvoice WHERE 1 = 1 " & IIf(kdNr > 0, " AND tblTrdinInvoice.RechnungsKundenNr=" & kdNr, "") & " and tblTrdinInvoice.Rechnungsdatum " & setSQLWhere("VERAG", "'AT'") & " AND tblTrdinInvoice.FilialenNr = 4814 ORDER BY tblTrdinInvoice.Rechnungsdatum, tblTrdinInvoice.Rechnungsnummer
|
||||
|
||||
|
||||
UNION ALL
|
||||
--PLOSE
|
||||
|
||||
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'PLOSE' as Lieferant,-1 as invoice_id, [plInv_SupplierRechnungsDatum] as Rechnungsdatum, cast([plInv_SupplierRechnungsNr] as nvarchar) as Rechnungsnummer,[plInv_PLOSEKundennummer] as Kundennummer,[plInv_Bruttobetrag] as Bruttobetrag,[plInv_Nettobetrag] as Nettobetrag,[plInv_MWSTBetrag] as MWST, [plInv_SupplierCountry] as Land, 'RE' as Art,[plInv_daId] as daId, cast(case when [plInv_daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM tblPLOSE_Inv_Data inner join Adressen on Adressen.PLOSEKundenNr = plInv_PLOSEKundennummer where 1 = 1 " & IIf(kdNr > 0, " AND Adressen.AdressenNr=" & kdNr, "") & " and [plInv_SupplierRechnungsDatum] " & setSQLWhere(SDLNrTmp, "plInv_SupplierCountry") & " Order by plInv_SupplierRechnungsDatum desc, [plInv_SupplierRechnungsNr]
|
||||
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'PLOSE' as Lieferant,-1 as invoice_id, [plInv_SupplierRechnungsDatum] as Rechnungsdatum, cast([plInv_SupplierRechnungsNr] as nvarchar) as Rechnungsnummer,[plInv_PLOSEKundennummer] as Kundennummer,[plInv_Bruttobetrag] as Bruttobetrag,[plInv_Nettobetrag] as Nettobetrag,[plInv_MWSTBetrag] as MWST, [plInv_SupplierCountry] as Land, 'RE' as Art,[plInv_daId] as daId, cast(case when [plInv_daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM tblPLOSE_Inv_Data inner join Adressen on Adressen.PLOSEKundenNr = plInv_PLOSEKundennummer where 1 = 1 " & IIf(kdNr > 0, " AND Adressen.AdressenNr=" & kdNr, "") & " and [plInv_SupplierRechnungsDatum] " & setSQLWhere("PLOSE", "plInv_SupplierCountry") & " Order by plInv_SupplierRechnungsDatum desc, [plInv_SupplierRechnungsNr]
|
||||
|
||||
UNION ALL
|
||||
|
||||
--RMC
|
||||
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'RMC' as Lieferant,-1 as invoice_id, [rmc_reDatum] as Rechnungsdatum,cast([rmc_reNr] as nvarchar) as Rechnungsnummer,rmc_kdNr as Kundennummer ,[rmc_betragBrutto] as Bruttobetrag,[rmc_betragNetto] as Nettobetrag,[rmc_betragMWST] as MWST, rmc_landKZ as Land, 'RE' as Art, [rmc_daId] as daId, cast(case when [rmc_daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM [VERAG].[dbo].[tblRMCImport] inner join Adressen on Adressen.WölflKundenNr = rmc_kdNr where 1 = 1 " & IIf(kdNr > 0, " AND AdressenNr=" & kdNr, "") & " and [rmc_reDatum] " & setSQLWhere(SDLNrTmp, "rmc_landKZ") & " order by rmc_reDatum, rmc_reNr
|
||||
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'RMC' as Lieferant,-1 as invoice_id, [rmc_reDatum] as Rechnungsdatum,cast([rmc_reNr] as nvarchar) as Rechnungsnummer,rmc_kdNr as Kundennummer ,[rmc_betragBrutto] as Bruttobetrag,[rmc_betragNetto] as Nettobetrag,[rmc_betragMWST] as MWST, rmc_landKZ as Land, 'RE' as Art, [rmc_daId] as daId, cast(case when [rmc_daId] is not null then 1 else 0 end as bit) as PDFvorhanden FROM [VERAG].[dbo].[tblRMCImport] inner join Adressen on Adressen.WölflKundenNr = rmc_kdNr where 1 = 1 " & IIf(kdNr > 0, " AND AdressenNr=" & kdNr, "") & " and [rmc_reDatum] " & setSQLWhere("RMC", "rmc_landKZ") & " order by rmc_reDatum, rmc_reNr
|
||||
|
||||
) as temp where 1=1 and temp.Rechnungsdatum" & setSQLWhere(SDLNrTmp, "temp.Land", True) & " order by Rechnungsdatum desc"
|
||||
) as temp where 1=1 and temp.Rechnungsdatum" & setSQLWhere(SDLNrTmp, "temp.Land") & " order by Rechnungsdatum desc"
|
||||
|
||||
|
||||
|
||||
@@ -326,20 +326,20 @@ Public Class usrcntlFremdrechnungen
|
||||
setPDFImages()
|
||||
End Sub
|
||||
|
||||
Private Function setSQLWhere(aktLieferant As String, land As String, Optional alle As Boolean = False) As String
|
||||
Private Function setSQLWhere(aktLieferant As String, land As String) As String
|
||||
|
||||
|
||||
Dim SQLWhere = " between '" & dat_Sum_Von.Value.ToShortDateString & "' and '" & dat_Sum_Bis.Value.ToShortDateString & "'"
|
||||
|
||||
If cbx.Checked AndAlso aktLieferant <> "IDS" AndAlso KUNDE IsNot Nothing Then
|
||||
|
||||
SQLWhere &= "AND ("
|
||||
'ORIGINAL-RECHNUNG senden wenn:
|
||||
'1. wenn die Rechnung in dem Land in dem er ansässig ist ausgestellt wurde (rumän. Kunde – Rechnung ausgestellt in Rumänien = z.B. IDS in RO getankt…)
|
||||
If land <> "" Then 'LandKZ vom Kunden muss auf ISO2 konvertiert werden, weil da ein Misch-Masch in der Datenbank herrscht!
|
||||
|
||||
If KUNDE.LandKz <> "" Then
|
||||
Dim landKZiso2 = ""
|
||||
|
||||
If land <> "" Then 'LandKZ vom Kunden muss auf ISO2 konvertiert werden, weil da ein Misch-Masch in der Datenbank herrscht!
|
||||
If KUNDE.LandKz <> "" Then
|
||||
If KUNDE.LandKz.Length = 2 Then
|
||||
landKZiso2 = KUNDE.LandKz
|
||||
ElseIf KUNDE.LandKz.Length = 3 Then
|
||||
@@ -348,23 +348,26 @@ Public Class usrcntlFremdrechnungen
|
||||
landKZiso2 = VERAG_PROG_ALLGEMEIN.cProgramFunctions.getISO2LandFromISO1Land(KUNDE.LandKz)
|
||||
End If
|
||||
|
||||
SQLWhere &= " AND " & land & " not in ('" & landKZiso2 & "')"
|
||||
SQLWhere &= " " & land & " in ('" & landKZiso2 & "')"
|
||||
End If
|
||||
End If
|
||||
|
||||
'2. wenn die Rechnung die Summe NULL aufweist
|
||||
'2. wenn die Rechnung die MWST-SUMME 0 aufweist!!!
|
||||
Select Case aktLieferant
|
||||
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
|
||||
Case "RMC" : If Not alle Then SQLWhere &= " AND rmc_betragBrutto <> 0" 'RMC
|
||||
Case "ALLE" : If alle Then SQLWhere &= " AND temp.Nettobetrag <> 0" 'ALLE
|
||||
Case "UTA" : SQLWhere &= " OR Gesamtbetrag_Umsatzsteuer_in_Darstellwährung = 0 " 'UTA bei UTA auch EPN ausblenden!
|
||||
Case "PLOSE" : SQLWhere &= " OR plInv_MWSTBetrag = 0" 'PLOSE
|
||||
Case "VERAG" : SQLWhere &= " OR tblTrdinInvoice.SteuerbetragLokal = 0" 'VERAG
|
||||
Case "MSE" : SQLWhere &= " OR total_vat_amount_euro = 0" 'MSE
|
||||
Case "RMC" : SQLWhere &= " OR rmc_betragMWST = 0" 'RMC
|
||||
Case "ALLE" : SQLWhere &= " OR temp.MWSt = 0" 'ALLE
|
||||
Case "UTA_" : SQLWhere &= " 1 <> 1"
|
||||
Case Else : SQLWhere &= " 1 <> 1"
|
||||
|
||||
End Select
|
||||
|
||||
'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 dtkeineMWST_ohneContraint As DataTable = dtkeineMWST.Select("Lieferant <> 'IDS' AND Land = '" & landKZiso2 & "'").CopyToDataTable
|
||||
Dim counter = 0
|
||||
Dim landBez As String = ""
|
||||
For Each row As DataRow In dtkeineMWST_ohneContraint.Rows
|
||||
@@ -372,7 +375,8 @@ Public Class usrcntlFremdrechnungen
|
||||
counter = counter + 1
|
||||
If (dtkeineMWST_ohneContraint.Rows.Count <> 0 And counter <> dtkeineMWST_ohneContraint.Rows.Count) Then landBez &= ","
|
||||
Next
|
||||
SQLWhere &= " AND " & land & " not in (" & landBez & ")"
|
||||
SQLWhere &= " OR " & land & " in (" & landBez & ")"
|
||||
If aktLieferant = "ALLE" Then SQLWhere &= " OR " & land & " in ('')" 'damit IDS ohne Land nicht ausgeschlossen wird.
|
||||
End If
|
||||
|
||||
'4. Rechnungen der Länder, in denen der Kunde selber MWST beantragt
|
||||
@@ -384,8 +388,9 @@ Public Class usrcntlFremdrechnungen
|
||||
counter = counter + 1
|
||||
If (dtKundeMWST.Rows.Count <> 0 And counter <> dtKundeMWST.Rows.Count) Then landBez &= ","
|
||||
Next
|
||||
SQLWhere &= " AND " & land & " not in (" & landBez & ")"
|
||||
SQLWhere &= " OR " & land & " in (" & landBez & ")"
|
||||
End If
|
||||
SQLWhere &= ")"
|
||||
|
||||
|
||||
'nicht NOTWENDIG!
|
||||
@@ -407,12 +412,13 @@ Public Class usrcntlFremdrechnungen
|
||||
Dim SQLWhere = ""
|
||||
|
||||
If cbx.Checked AndAlso KUNDE IsNot Nothing Then
|
||||
|
||||
SQLWhere &= "AND ("
|
||||
'ORIGINAL-RECHNUNG senden wenn:
|
||||
'1. wenn die Rechnung in dem Land in dem er ansässig ist ausgestellt wurde (rumän. Kunde – Rechnung ausgestellt in Rumänien = z.B. IDS in RO getankt…)
|
||||
If land <> "" Then
|
||||
If KUNDE.LandKz <> "" Then
|
||||
Dim landKZiso2 = ""
|
||||
|
||||
If KUNDE.LandKz <> "" Then
|
||||
|
||||
If KUNDE.LandKz.Length = 2 Then
|
||||
landKZiso2 = KUNDE.LandKz
|
||||
ElseIf KUNDE.LandKz.Length = 3 Then
|
||||
@@ -421,18 +427,19 @@ Public Class usrcntlFremdrechnungen
|
||||
landKZiso2 = VERAG_PROG_ALLGEMEIN.cProgramFunctions.getISO2LandFromISO1Land(KUNDE.LandKz)
|
||||
End If
|
||||
|
||||
SQLWhere &= " AND " & land & " not in ('" & landKZiso2 & "')"
|
||||
End If
|
||||
If land <> "" Then SQLWhere &= " " & land & " in ('" & landKZiso2 & "')"
|
||||
End If
|
||||
|
||||
|
||||
|
||||
'2. wenn die Rechnung die Summe NULL aufweist
|
||||
Select Case aktLieferant
|
||||
Case "IDS" : If Not alle Then SQLWhere &= " AND [AmminclVAT] <> 0" 'IDS
|
||||
Case "IDS" : If Not alle Then SQLWhere &= " OR [AmminclVAT] = 0" 'IDS
|
||||
End Select
|
||||
|
||||
'3. Rechnungen der Länder in denen der Kunde keine MWST erstattet bekommt
|
||||
'3. Rechnungen der Länder in denen der Kunde keine MWST erstattet bekommt (auch nicht auf Diesel -> IDS)
|
||||
If land <> "" AndAlso dtkeineMWST.Rows.Count > 0 Then
|
||||
Dim dtkeineMWST_IDS As DataTable = dtkeineMWST.Select("Lieferant = 'IDS'").CopyToDataTable
|
||||
Dim dtkeineMWST_IDS As DataTable = dtkeineMWST.Select("Lieferant = '' AND Land = '" & landKZiso2 & "'").CopyToDataTable
|
||||
Dim counter = 0
|
||||
Dim landBez As String = ""
|
||||
For Each row As DataRow In dtkeineMWST_IDS.Rows
|
||||
@@ -440,7 +447,7 @@ Public Class usrcntlFremdrechnungen
|
||||
counter = counter + 1
|
||||
If (dtkeineMWST_IDS.Rows.Count <> 0 And counter <> dtkeineMWST_IDS.Rows.Count) Then landBez &= ","
|
||||
Next
|
||||
SQLWhere &= " AND " & land & " not in (" & landBez & ")"
|
||||
SQLWhere &= " OR " & land & " in (" & landBez & ")"
|
||||
End If
|
||||
|
||||
|
||||
@@ -454,9 +461,9 @@ Public Class usrcntlFremdrechnungen
|
||||
counter = counter + 1
|
||||
If (dtKundeMWST.Rows.Count <> 0 And counter <> dtKundeMWST.Rows.Count) Then landBez &= ","
|
||||
Next
|
||||
SQLWhere &= " AND " & land & " not in (" & landBez & ")"
|
||||
SQLWhere &= " OR " & land & " in (" & landBez & ")"
|
||||
End If
|
||||
|
||||
SQLWhere &= ")"
|
||||
End If
|
||||
|
||||
Return SQLWhere
|
||||
|
||||
Reference in New Issue
Block a user