|
|
|
|
@@ -245,28 +245,28 @@ Public Class usrcntlFremdrechnungen
|
|
|
|
|
|
|
|
|
|
'IDS
|
|
|
|
|
Case "IDS" : SQL_STR = "SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") &
|
|
|
|
|
" invoice_id,[tbl_IDS_Kunden].KdNrVERAG as AdressenNr, [YearMonthDay] as Rechnungsdatum,[Invoicenumber] as Rechnungsnummer, tblIDSInvoicesNew.CustomerCode as Kundennummer,[daId],[TransactionVolume] as Transaktionsmenge,[AmminclVAT] as Bruttobetrag,[TotalNetAmount] as Nettobetrag,[VATAmount] as MWSt, cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden, cast(1 as bit) as OrigRE FROM tblIDSInvoicesNew inner join [VERAG].[dbo].[tbl_IDS_Kunden] on tblIDSInvoicesNew.CustomerCode = tbl_IDS_Kunden.CustomerCode WHERE tblIDSInvoicesNew.[CustomerCode] in (SELECT distinct([CustomerCode]) FROM [VERAG].[dbo].[tbl_IDS_Kunden] WHERE 1 = 1 AND isnull([tbl_IDS_Kunden].KdNrAlt, 0) = 0 " & sqlfehlendePDF & IIf(kdNr > 0, " AND [KdNrVERAG]=" & kdNr, "") & ") and [YearMonthDay] " & setSQLWhere(SDLNrTmp, "") & whereKundennrKreisLieferanten & " order by [YearMonthDay] desc, [Invoicenumber]"
|
|
|
|
|
" invoice_id,[tbl_IDS_Kunden].KdNrVERAG as AdressenNr, [YearMonthDay] as Rechnungsdatum,[Invoicenumber] as Rechnungsnummer, tblIDSInvoicesNew.CustomerCode as Kundennummer,[daId],[TransactionVolume] as Transaktionsmenge,[AmminclVAT] as Bruttobetrag,[TotalNetAmount] as Nettobetrag,[VATAmount] as MWSt, cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden, cast(1 as bit) as OrigRE FROM tblIDSInvoicesNew inner join [VERAG].[dbo].[tbl_IDS_Kunden] on tblIDSInvoicesNew.CustomerCode = tbl_IDS_Kunden.CustomerCode WHERE tblIDSInvoicesNew.[CustomerCode] in (SELECT distinct([CustomerCode]) FROM [VERAG].[dbo].[tbl_IDS_Kunden] WHERE 1 = 1 AND isnull([tbl_IDS_Kunden].KdNrAlt, 0) = 0 " & IIf(kdNr > 0, " AND [KdNrVERAG]=" & kdNr, whereKundennrKreisLieferanten) & ") " & sqlfehlendePDF & " and [YearMonthDay] " & setSQLWhere(SDLNrTmp, "") & " order by [YearMonthDay] desc, [Invoicenumber]"
|
|
|
|
|
|
|
|
|
|
'UTA
|
|
|
|
|
Case "UTA" : SQL_STR = "SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") &
|
|
|
|
|
" Adressen.AdressenNr, Adressen.[Name 1], [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, cast(archiv as bit) as archiv,cast(case when InvToCustomer is not null then 1 else 0 end as bit) as OrigRE FROM [VERAG].[dbo].[tblUTAImportNew] inner join adressen on Kundennummer = UTAKundenNr where 1 = 1 " & sqlfehlendePDF & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " AND [Rechnungsdatum] " & setSQLWhere(SDLNrTmp, "Lieferland_ISO2") & whereKundennrKreisLieferanten & " group by Adressen.AdressenNr, Adressen.[Name 1],[Rechnungsnummer_pro_Lieferland],[Rechnungsdatum],Kundennummer,[daId],[Lieferland_ISO2], archiv, InvToCustomer "
|
|
|
|
|
" Adressen.AdressenNr, Adressen.[Name 1], [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, cast(archiv as bit) as archiv,cast(isnull(InvToCustomer, 0) as bit) as OrigRE FROM [VERAG].[dbo].[tblUTAImportNew] inner join adressen on Kundennummer = UTAKundenNr where 1 = 1 " & sqlfehlendePDF & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " AND [Rechnungsdatum] " & setSQLWhere(SDLNrTmp, "Lieferland_ISO2") & whereKundennrKreisLieferanten & " group by Adressen.AdressenNr, Adressen.[Name 1],[Rechnungsnummer_pro_Lieferland],[Rechnungsdatum],Kundennummer,[daId],[Lieferland_ISO2], archiv, InvToCustomer "
|
|
|
|
|
|
|
|
|
|
SQL_STR &= " UNION ALL SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") & " Adressen.AdressenNr, Adressen.[Name 1],[Datum], [RechnungsNr],[KundenNr],0,0,0,[daId],'',[DocumentTyp], cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden, cast(0 as bit) as archiv, cast(0 as bit) as OrigRE FROM [VERAG].[dbo].[tblUTADocuments] inner join adressen on KundenNr = UTAKundenNr where 1 = 1 " & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " and [Datum] " & setSQLWhere("_", "") & whereKundennrKreisLieferanten & " order by Rechnungsdatum desc"
|
|
|
|
|
|
|
|
|
|
'PLOSE
|
|
|
|
|
Case "PLOSE" : SQL_STR = "SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") &
|
|
|
|
|
" Adressen.AdressenNr, Adressen.[Name 1],[plInv_SupplierRechnungsDatum] as Rechnungsdatum, [plInv_SupplierRechnungsNr] as Rechnungsnummer,[plInv_PLOSEKundennummer] as Kundennummer,[plInv_Nettobetrag] as Nettobetrag,[plInv_MWSTBetrag] as MWST,[plInv_Bruttobetrag] as Bruttobetrag,[plInv_daId] as daId, [plInv_SupplierCountry] as Land, cast(case when [plInv_daId] is not null then 1 else 0 end as bit) as PDFvorhanden, plInv_Archiv as archiv, cast(case when plInv_InvToCustomer is not null then 1 else 0 end as bit) as OrigRE FROM tblPLOSE_Inv_Data inner join Adressen on Adressen.PLOSEKundenNr = plInv_PLOSEKundennummer where 1 = 1 " & sqlfehlendePDF_PLOSE & IIf(kdNr > 0, " AND Adressen.AdressenNr=" & kdNr, "") & " and [plInv_SupplierRechnungsDatum] " & setSQLWhere(SDLNrTmp, "plInv_SupplierCountry") & whereKundennrKreisLieferanten & " Order by plInv_SupplierRechnungsDatum desc, [plInv_SupplierRechnungsNr]"
|
|
|
|
|
" Adressen.AdressenNr, Adressen.[Name 1],[plInv_SupplierRechnungsDatum] as Rechnungsdatum, [plInv_SupplierRechnungsNr] as Rechnungsnummer,[plInv_PLOSEKundennummer] as Kundennummer,[plInv_Nettobetrag] as Nettobetrag,[plInv_MWSTBetrag] as MWST,[plInv_Bruttobetrag] as Bruttobetrag,[plInv_daId] as daId, [plInv_SupplierCountry] as Land, cast(case when [plInv_daId] is not null then 1 else 0 end as bit) as PDFvorhanden, plInv_Archiv as archiv, cast(isnull(plInv_InvToCustomer, 0) as bit) as OrigRE FROM tblPLOSE_Inv_Data inner join Adressen on Adressen.PLOSEKundenNr = plInv_PLOSEKundennummer where 1 = 1 " & sqlfehlendePDF_PLOSE & IIf(kdNr > 0, " AND Adressen.AdressenNr=" & kdNr, "") & " and [plInv_SupplierRechnungsDatum] " & setSQLWhere(SDLNrTmp, "plInv_SupplierCountry") & whereKundennrKreisLieferanten & " Order by plInv_SupplierRechnungsDatum desc, [plInv_SupplierRechnungsNr]"
|
|
|
|
|
|
|
|
|
|
'MSE
|
|
|
|
|
Case "MSE" : SQL_STR = "SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") &
|
|
|
|
|
" partner_customer_number as AdressenNr, customer_name as [Name 1], [invoice_date] as Rechnungsdatum, [invoice_id] as Rechnungsnummer/*,[invoice_nr]*/,[customer_number] as Kundennummer, daId, [total_amount_euro] as Bruttobetrag ,[total_vat_amount_euro] as MWST,[country] as Land, cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden, archiv, cast(case when InvToCustomer is not null then 1 else 0 end as bit) as OrigRE FROM tblMSEInvoices inner join tblMSECustomers on customer_id = [customer_number] where 1 = 1 " & sqlfehlendePDF & IIf(kdNr > 0, " AND [partner_customer_number]=" & kdNr, "") & " and [invoice_date] " & setSQLWhere(SDLNrTmp, "country") & whereKundennrKreisLieferanten & " order by invoice_date desc, invoice_id"
|
|
|
|
|
" partner_customer_number as AdressenNr, customer_name as [Name 1], [invoice_date] as Rechnungsdatum, [invoice_id] as Rechnungsnummer/*,[invoice_nr]*/,[customer_number] as Kundennummer, daId, [total_amount_euro] as Bruttobetrag ,[total_vat_amount_euro] as MWST,[country] as Land, cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden, archiv, cast(isnull(InvToCustomer, 0) as bit) as OrigRE FROM tblMSEInvoices inner join tblMSECustomers on customer_id = [customer_number] where 1 = 1 " & sqlfehlendePDF & IIf(kdNr > 0, " AND [partner_customer_number]=" & kdNr, "") & " and [invoice_date] " & setSQLWhere(SDLNrTmp, "country") & whereKundennrKreisLieferanten & " order by invoice_date desc, invoice_id"
|
|
|
|
|
|
|
|
|
|
'VERAG
|
|
|
|
|
Case "VERAG" : SQL_STR = "SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") &
|
|
|
|
|
" Adressen.AdressenNr, Adressen.[Name 1], tblTrdinInvoice.Rechnungsdatum, tblTrdinInvoice.Rechnungsnummer , tblTrdinInvoice.RechnungsbetragLokal as Bruttobetrag, 1 as daId, cast(1 as bit) as PDFvorhanden FROM tblTrdinInvoice inner join Adressen on KundenNrZentrale = AdressenNr WHERE 1 = 1 " & sqlfehlendePDF_VERAG & IIf(kdNr > 0, " AND tblTrdinInvoice.RechnungsKundenNr=" & kdNr, "") & " AND tblTrdinInvoice.FilialenNr = 4814 and tblTrdinInvoice.Rechnungsdatum " & setSQLWhere(SDLNrTmp, "'AT'") & " ORDER BY tblTrdinInvoice.Rechnungsdatum desc, tblTrdinInvoice.Rechnungsnummer"
|
|
|
|
|
'RMC
|
|
|
|
|
Case "RMC" : SQL_STR = "SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahlTop, "") &
|
|
|
|
|
"Adressen.AdressenNr, Adressen.[Name 1],[rmc_reDatum] as Rechnungsdatum,[rmc_reNr] as Rechnungsnummer,rmc_kdNr as Kundennummer,[rmc_betragNetto] as Nettobetrag,[rmc_betragBrutto] as Bruttobetrag,[rmc_waehrung] as Währung ,[rmc_euroBrutto] as Bruttobetrag,[rmc_daId] as daId,[rmc_betragMWST] as MWST,rmc_landKZ as Land, cast(case when [rmc_daId] is not null then 1 else 0 end as bit) as PDFvorhanden, rmc_archiv as archiv, cast(case when InvToCustomer is not null then 1 else 0 end as bit) as OrigRE FROM [VERAG].[dbo].[tblRMCImport] inner join Adressen on Adressen.WölflKundenNr = rmc_kdNr where 1 = 1 " & sqlfehlendePDF_RMC & IIf(kdNr > 0, " AND AdressenNr=" & kdNr, "") & " and [rmc_reDatum] " & setSQLWhere(SDLNrTmp, "rmc_landKZ") & whereKundennrKreisLieferanten & " order by rmc_reDatum desc, rmc_reNr"
|
|
|
|
|
"Adressen.AdressenNr, Adressen.[Name 1],[rmc_reDatum] as Rechnungsdatum,[rmc_reNr] as Rechnungsnummer,rmc_kdNr as Kundennummer,[rmc_betragNetto] as Nettobetrag,[rmc_betragBrutto] as Bruttobetrag,[rmc_waehrung] as Währung ,[rmc_euroBrutto] as Bruttobetrag,[rmc_daId] as daId,[rmc_betragMWST] as MWST,rmc_landKZ as Land, cast(case when [rmc_daId] is not null then 1 else 0 end as bit) as PDFvorhanden, rmc_archiv as archiv, cast(isnull(InvToCustomer, 0) as bit) as OrigRE FROM [VERAG].[dbo].[tblRMCImport] inner join Adressen on Adressen.WölflKundenNr = rmc_kdNr where 1 = 1 " & sqlfehlendePDF_RMC & IIf(kdNr > 0, " AND AdressenNr=" & kdNr, "") & " and [rmc_reDatum] " & setSQLWhere(SDLNrTmp, "rmc_landKZ") & whereKundennrKreisLieferanten & " order by rmc_reDatum desc, rmc_reNr"
|
|
|
|
|
|
|
|
|
|
Case "ALLE" : Dim anzahl As Integer = anzahlTop / 6 : SQL_STR = " select * from (SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") &
|
|
|
|
|
"
|
|
|
|
|
@@ -277,12 +277,12 @@ Public Class usrcntlFremdrechnungen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--MSE
|
|
|
|
|
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'MSE' as Lieferant,-1 as invoice_id,partner_customer_number as AdressenNr, [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, cast(case when InvToCustomer is not null then 1 else 0 end as bit) as OrigRE FROM tblMSEInvoices inner join tblMSECustomers on customer_id = [customer_number] where 1 = 1 " & sqlfehlendePDF & IIf(kdNr > 0, " AND [partner_customer_number]=" & kdNr, "") & " and [invoice_date] " & setSQLWhere("MSE", "country") & whereKundennrKreisLieferanten & " --order by invoice_date, invoice_id
|
|
|
|
|
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'MSE' as Lieferant,-1 as invoice_id,partner_customer_number as AdressenNr, [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, cast(isnull(InvToCustomer, 0) as bit) as OrigRE FROM tblMSEInvoices inner join tblMSECustomers on customer_id = [customer_number] where 1 = 1 " & sqlfehlendePDF & IIf(kdNr > 0, " AND [partner_customer_number]=" & kdNr, "") & " and [invoice_date] " & setSQLWhere("MSE", "country") & whereKundennrKreisLieferanten & " --order by invoice_date, invoice_id
|
|
|
|
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
|
|
|
|
--UTA
|
|
|
|
|
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'UTA' as Lieferant,-1 as invoice_id,Adressen.AdressenNr, [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, cast(case when InvToCustomer is not null then 1 else 0 end as bit) as OrigRE FROM [VERAG].[dbo].[tblUTAImportNew] inner join adressen on Kundennummer = UTAKundenNr where 1 = 1 " & sqlfehlendePDF & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " and [Rechnungsdatum] " & setSQLWhere("UTA", "Lieferland_ISO2") & whereKundennrKreisLieferanten & " group by [Rechnungsnummer_pro_Lieferland],[Rechnungsdatum],Kundennummer,AdressenNr,[daId],[Lieferland_ISO2], InvToCustomer UNION ALL SELECT 'UTA',-1,AdressenNr, [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, cast(0 as bit) as OrigRE FROM [VERAG].[dbo].[tblUTADocuments] inner join adressen on KundenNr = UTAKundenNr where AdressenNr = " & kdNr & " AND Datum " & setSQLWhere("UTA_", "") & whereKundennrKreisLieferanten & " --order by Rechnungsnummer desc
|
|
|
|
|
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'UTA' as Lieferant,-1 as invoice_id,Adressen.AdressenNr, [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, cast(isnull(InvToCustomer, 0) as bit) as OrigRE FROM [VERAG].[dbo].[tblUTAImportNew] inner join adressen on Kundennummer = UTAKundenNr where 1 = 1 " & sqlfehlendePDF & IIf(kdNr > 0, " AND [AdressenNr]=" & kdNr, "") & " and [Rechnungsdatum] " & setSQLWhere("UTA", "Lieferland_ISO2") & whereKundennrKreisLieferanten & " group by [Rechnungsnummer_pro_Lieferland],[Rechnungsdatum],Kundennummer,AdressenNr,[daId],[Lieferland_ISO2], InvToCustomer UNION ALL SELECT 'UTA',-1,AdressenNr, [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, cast(0 as bit) as OrigRE FROM [VERAG].[dbo].[tblUTADocuments] inner join adressen on KundenNr = UTAKundenNr where AdressenNr = " & kdNr & " AND Datum " & setSQLWhere("UTA_", "") & whereKundennrKreisLieferanten & " --order by Rechnungsnummer desc
|
|
|
|
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
--VERAG
|
|
|
|
|
@@ -293,12 +293,12 @@ Public Class usrcntlFremdrechnungen
|
|
|
|
|
UNION ALL
|
|
|
|
|
--PLOSE
|
|
|
|
|
|
|
|
|
|
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'PLOSE' as Lieferant,-1 as invoice_id,Adressen.AdressenNr, [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, cast(case when plInv_InvToCustomer is not null then 1 else 0 end as bit) as OrigRE FROM tblPLOSE_Inv_Data inner join Adressen on Adressen.PLOSEKundenNr = plInv_PLOSEKundennummer where 1 = 1 " & sqlfehlendePDF_PLOSE & IIf(kdNr > 0, " AND Adressen.AdressenNr=" & kdNr, "") & " and [plInv_SupplierRechnungsDatum] " & setSQLWhere("PLOSE", "plInv_SupplierCountry") & whereKundennrKreisLieferanten & "-- Order by plInv_SupplierRechnungsDatum desc, [plInv_SupplierRechnungsNr]
|
|
|
|
|
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'PLOSE' as Lieferant,-1 as invoice_id,Adressen.AdressenNr, [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, cast(isnull(plInv_InvToCustomer, 0) as bit) as OrigRE FROM tblPLOSE_Inv_Data inner join Adressen on Adressen.PLOSEKundenNr = plInv_PLOSEKundennummer where 1 = 1 " & sqlfehlendePDF_PLOSE & IIf(kdNr > 0, " AND Adressen.AdressenNr=" & kdNr, "") & " and [plInv_SupplierRechnungsDatum] " & setSQLWhere("PLOSE", "plInv_SupplierCountry") & whereKundennrKreisLieferanten & "-- Order by plInv_SupplierRechnungsDatum desc, [plInv_SupplierRechnungsNr]
|
|
|
|
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
|
|
|
|
--RMC
|
|
|
|
|
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'RMC' as Lieferant,-1 as invoice_id,Adressen.AdressenNr, [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, cast(case when InvToCustomer is not null then 1 else 0 end as bit) as OrigRE FROM [VERAG].[dbo].[tblRMCImport] inner join Adressen on Adressen.WölflKundenNr = rmc_kdNr where 1 = 1 " & sqlfehlendePDF_RMC & IIf(kdNr > 0, " AND AdressenNr=" & kdNr, "") & " and [rmc_reDatum] " & setSQLWhere("RMC", "rmc_landKZ") & whereKundennrKreisLieferanten & "-- order by rmc_reDatum, rmc_reNr
|
|
|
|
|
SELECT " & IIf(cbxMax1000Eintrage.Checked, " top " & anzahl, "") & " 'RMC' as Lieferant,-1 as invoice_id,Adressen.AdressenNr, [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, cast(isnull(InvToCustomer, 0) as bit) as OrigRE FROM [VERAG].[dbo].[tblRMCImport] inner join Adressen on Adressen.WölflKundenNr = rmc_kdNr where 1 = 1 " & sqlfehlendePDF_RMC & IIf(kdNr > 0, " AND AdressenNr=" & kdNr, "") & " and [rmc_reDatum] " & setSQLWhere("RMC", "rmc_landKZ") & whereKundennrKreisLieferanten & "-- order by rmc_reDatum, rmc_reNr
|
|
|
|
|
|
|
|
|
|
) as temp where 1=1 and temp.Rechnungsdatum" & setSQLWhere(SDLNrTmp, "temp.Land") & whereKundennrKreisAlle & " order by Rechnungsdatum desc"
|
|
|
|
|
|
|
|
|
|
@@ -481,7 +481,7 @@ Public Class usrcntlFremdrechnungen
|
|
|
|
|
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Private Function setSQLDetailWhere(aktLieferant As String, land As String, Optional alle As Boolean = False, Optional KundenNr_Input As Integer = -1, Optional dtKundeMWSTTemp As DataTable = Nothing) As String
|
|
|
|
|
Private Function setSQLDetailWhere(aktLieferant As String, land As String) As String
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'das hier ist nur PRO KUNDE möglich!!!
|
|
|
|
|
@@ -885,13 +885,12 @@ Public Class usrcntlFremdrechnungen
|
|
|
|
|
For Each kvp In groups
|
|
|
|
|
|
|
|
|
|
Dim TextHTMLtable = ""
|
|
|
|
|
|
|
|
|
|
Dim pdflist = createEMailTable(TextHTMLtable, kvp, cbx.Checked)
|
|
|
|
|
|
|
|
|
|
If Not cbxMailoeffnen.Checked And Not pdflist.Any() Then
|
|
|
|
|
If Not cbxMailoeffnen.Checked And pdflist.Count > 0 Then
|
|
|
|
|
|
|
|
|
|
Else
|
|
|
|
|
createEmail(kvp.Key, TextHTMLtable, pdflist)
|
|
|
|
|
If pdflist.Count > 0 Then createEmail(kvp.Key, TextHTMLtable, pdflist)
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
@@ -946,11 +945,6 @@ Public Class usrcntlFremdrechnungen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dim sendÍnvoice As Boolean = IIf(onlyRelevantInvioces AndAlso KUNDE.KundenNr = 0, False, True)
|
|
|
|
|
|
|
|
|
|
If onlyRelevantInvioces AndAlso erw.kde_keineMWSt AndAlso Lieferant <> "IDS" Then 'weil ISD wieder sonderlogik -> siehe weiter unten!
|
|
|
|
|
sendÍnvoice = True 'dann immer mitschicken!
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
'ORIGINAL-RECHNUNG senden wenn:
|
|
|
|
|
If onlyRelevantInvioces Then
|
|
|
|
|
@@ -1026,20 +1020,20 @@ Public Class usrcntlFremdrechnungen
|
|
|
|
|
Else
|
|
|
|
|
|
|
|
|
|
TextHTMLtable &= "<tr>"
|
|
|
|
|
TextHTMLtable &= "<td><b>" & Lieferant & "</b></td>"
|
|
|
|
|
TextHTMLtable &= "<td><b>" & row.Cells("Land").Value & "</b></td>"
|
|
|
|
|
TextHTMLtable &= "<td><b>" & row.Cells("Rechnungsdatum").Value & "</b></td>"
|
|
|
|
|
TextHTMLtable &= "<td><b>" & Lieferant & "</b></td>"
|
|
|
|
|
TextHTMLtable &= "<td><b>" & row.Cells("Land").Value & "</b></td>"
|
|
|
|
|
TextHTMLtable &= "<td><b>" & row.Cells("Rechnungsdatum").Value & "</b></td>"
|
|
|
|
|
|
|
|
|
|
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())
|
|
|
|
|
TextHTMLtable &= "<td><b>" & DS.da_name & "</b></td>"
|
|
|
|
|
Else
|
|
|
|
|
TextHTMLtable &= "<td><b>-</b></td>"
|
|
|
|
|
End If
|
|
|
|
|
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())
|
|
|
|
|
TextHTMLtable &= "<td><b>" & DS.da_name & "</b></td>"
|
|
|
|
|
Else
|
|
|
|
|
TextHTMLtable &= "<td><b>-</b></td>"
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
TextHTMLtable &= "</tr>"
|
|
|
|
|
TextHTMLtable &= "</tr>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
@@ -1439,18 +1433,12 @@ Public Class usrcntlFremdrechnungen
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Private Function initDGVRechnungsdetails(rechnugnsID As Integer, Optional setDatatable As Boolean = False, Optional KundenNr_Input As Integer = -1, Optional dtKundeMWSTTemp As DataTable = Nothing) As DataTable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If dtKundeMWSTTemp Is Nothing AndAlso KundenNr_Input > 0 Then
|
|
|
|
|
dtKundeMWSTTemp = (New SQL).loadDgvBySql("select LandKz from tblKundenMWST where KdNr = " & KundenNr_Input, "FMZOLL")
|
|
|
|
|
End If
|
|
|
|
|
Private Function initDGVRechnungsdetails(rechnugnsID As Integer, Optional setDatatable As Boolean = False, Optional KundenNr_Input As Integer = -1) As DataTable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dim sql = " select [YearMonthDay] as Rechnungsdatum,[Invoicenumber] as Rechnungsnummer, CustomerCode as Kundennummer,[daId],[TransactionVolume] as Transaktionsmenge,[AmminclVAT] as Bruttobetrag,[TotalNetAmount] as Nettobetrag,[VATAmount] as MWSt,
|
|
|
|
|
cast(case when [daId] is not null then 1 else 0 end as bit) as PDFvorhanden,cast(isnull(InvToCustomer, 0) as bit) as OrigRE ,[Country] as Land
|
|
|
|
|
FROM [VERAG].[dbo].[tblIDSInvoicesNewSplittedByCountry] WHERE [TotalInvoiceId] = " & rechnugnsID & setSQLDetailWhere(aktLieferant, "Country", , KundenNr_Input, dtKundeMWSTTemp)
|
|
|
|
|
FROM [VERAG].[dbo].[tblIDSInvoicesNewSplittedByCountry] WHERE [TotalInvoiceId] = " & rechnugnsID & setSQLDetailWhere(aktLieferant, "Country")
|
|
|
|
|
|
|
|
|
|
If setDatatable Then
|
|
|
|
|
|
|
|
|
|
|