diff --git a/SDL/USTV/frmMDM_USTVAntrag.vb b/SDL/USTV/frmMDM_USTVAntrag.vb index 0179de1a..404d0170 100644 --- a/SDL/USTV/frmMDM_USTVAntrag.vb +++ b/SDL/USTV/frmMDM_USTVAntrag.vb @@ -470,7 +470,7 @@ Public Class frmMDM_USTVAntrag AddHandler plose.Click, AddressOf mnuItemAuftrauege_Clicked End If - If False Then 'wenn INFO von PLOSE WÄHRUNGSCODE IN INV_DATA, dann freischalten + If True Then 'wenn INFO von PLOSE WÄHRUNGSCODE IN INV_DATA, dann freischalten If Not ContextMenuStrip2.Items.ContainsKey("ploseneu") Then Dim plose = New ToolStripMenuItem() With {.Text = "Plose NEUE LOGIK", .Name = "ploseneu", .Font = New Font(Me.Font.FontFamily, Me.Font.Size)} ContextMenuStrip2.Items.Add(plose) @@ -592,15 +592,14 @@ Public Class frmMDM_USTVAntrag USTV_POS.UStVPo_ReNr = ANTRAG.plose_RechnungsNr.ToString USTV_POS.UStVPo_SchnittstellenNr = bytSchnittstellenNr - If MWSTSummenAusBeleg Then - USTV_POS.UStVPo_daId = ANTRAG.plose_daId - Else - USTV_POS.UStVPo_daId = SQL.getValueTxtBySql("SELECT TOP(1) [plInv_daId] FROM [tblPLOSE_Inv_Data] where plInv_SupplierRechnungsDatum='" & USTV_POS.UStVPo_ReDat & "' and plInv_SupplierRechnungsNr='" & USTV_POS.UStVPo_ReNr & "' and plInv_SupplierCountry='" & Antrag_LandKz & "' AND [plInv_daId] is not null", "FMZOLL") - End If - - If Not alreadyExists(USTV_ANTRAG.UStVAn_KuNr, USTV_ANTRAG.UStVAn_LandNr, USTV_POS) Then + If MWSTSummenAusBeleg AndAlso ANTRAG.plose_daId IsNot Nothing Then + USTV_POS.UStVPo_daId = ANTRAG.plose_daId + Else + USTV_POS.UStVPo_daId = sql.getValueTxtBySql("SELECT TOP(1) [plInv_daId] FROM [tblPLOSE_Inv_Data] where plInv_SupplierRechnungsDatum='" & USTV_POS.UStVPo_ReDat & "' and plInv_SupplierRechnungsNr='" & USTV_POS.UStVPo_ReNr & "' and plInv_SupplierCountry='" & Antrag_LandKz & "' AND [plInv_daId] is not null", "FMZOLL") + End If + USTV_POS.UStVPo_Schnittstelle = True USTV_POS.UStVPo_Leistungsbezeichnung = "Maut" USTV_POS.UStVPo_Leistender = ANTRAG.plose_Lieferant @@ -620,6 +619,44 @@ Public Class frmMDM_USTVAntrag ' MsgBox(ANTRAG.plose_Lieferant & " - " & ANTRAG.plose_RechnungsDatum & " - " & ANTRAG.plose_RechnungsNr & " :::::::::: " & CDbl(ANTRAG.plose_MWSTBetrag).ToString("C2")) Else 'TODO - hier Umrechnungslogik von FRMDW und EUR und EUR/FRMDWR für Belegsebene + Dim umrechKurs As Double = 1 + + If USTV_ANTRAG.UStVAn_Währungscode = ANTRAG.plose_WaehrungAbbuchung Then + USTV_POS.UStVPo_USteuerbetragEUR = ANTRAG.plose_MWSTBetragWaehrungAbbuchung + USTV_POS.UStVPo_Umrechnungskurs = ANTRAG.plose_MWSTBetrag / ANTRAG.plose_MWSTBetragWaehrungAbbuchung + USTV_POS.UStVPo_USteuerbetrag = ANTRAG.plose_MWSTBetrag + + Else + Dim kurs As New cEZB_Waehrungskurse(USTV_ANTRAG.UStVAn_Währungscode) + Dim UST_EUR = ANTRAG.plose_MWSTBetrag + Dim UST_org = ANTRAG.plose_MWSTBetrag + + If USTV_ANTRAG.UStVAn_Währungscode <> "EUR" AndAlso ANTRAG.plose_WaehrungAbbuchung = "EUR" Then + + UST_org = Math.Round(kurs.EXCHANGE_EURTOCUR(UST_EUR, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) + + ElseIf USTV_ANTRAG.UStVAn_Währungscode = "EUR" AndAlso ANTRAG.plose_WaehrungAbbuchung <> "EUR" Then + + UST_EUR = Math.Round(kurs.EXCHANGE_CURTOEUR(UST_org, USTV_ANTRAG.UStVAn_Währungscode, CDate(USTV_POS.UStVPo_ReDat)), 2) + + End If + + + If (UST_org > 0 AndAlso UST_org <> UST_EUR) Then + umrechKurs = Math.Floor((UST_org / UST_EUR * 100 + 0.5)) / 100 + End If + + + If UST_org > 0 Then + USTV_POS.UStVPo_USteuerbetragEUR = UST_EUR + USTV_POS.UStVPo_Umrechnungskurs = umrechKurs + USTV_POS.UStVPo_USteuerbetrag = UST_org + End If + + + + End If + End If diff --git a/SDL/USTV/usrCntlUSTV.vb b/SDL/USTV/usrCntlUSTV.vb index 5b26c10f..5ead030d 100644 --- a/SDL/USTV/usrCntlUSTV.vb +++ b/SDL/USTV/usrCntlUSTV.vb @@ -367,7 +367,7 @@ Public Class usrCntlUSTV AddHandler plose.Click, AddressOf mnuItemAuftrauege_Clicked End If - If False Then 'wenn INFO von PLOSE WÄHRUNGSCODE IN INV_DATA, dann freischalten + If True Then 'wenn INFO von PLOSE WÄHRUNGSCODE IN INV_DATA, dann freischalten If Not ContextMenuStrip2.Items.ContainsKey("ploseneu") Then Dim plose = New ToolStripMenuItem() With {.Text = "Plose-NEUE LOGIK", .Name = "ploseneu", .Font = New Font(Me.Font.FontFamily, Me.Font.Size)} ContextMenuStrip2.Items.Add(plose) diff --git a/SDL/mdm/usrcntlFremdrechnungen.vb b/SDL/mdm/usrcntlFremdrechnungen.vb index 9e6f2d54..515d1fc3 100644 --- a/SDL/mdm/usrcntlFremdrechnungen.vb +++ b/SDL/mdm/usrcntlFremdrechnungen.vb @@ -310,7 +310,7 @@ Public Class usrcntlFremdrechnungen 'IDS Case 100 : SQL_STR = "SELECT " & IIf(cbxMax200Eintrage.Checked, " top 200 ", "") & - " [YearMonthDay] as Rechnungsdatum,[Invoicenumber] as Rechnungsnummer,[daId], cast(case when [daId] is not null then 1 else 0 end as bit) as PDF FROM tblIDSInvoicesNew WHERE [CustomerCode] = (SELECT TOP 1 [CustomerCode] FROM [VERAG].[dbo].[tbl_IDS_Kunden] WHERE [KdNrVERAG]=" & kdNr & " AND KdNrAlt =0 ORDER BY Zeitstempel DESC) order by [YearMonthDay], [Invoicenumber]" + " [YearMonthDay] as Rechnungsdatum,[Invoicenumber] as Rechnungsnummer,[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 PDF FROM tblIDSInvoicesNew WHERE [CustomerCode] = (SELECT TOP 1 [CustomerCode] FROM [VERAG].[dbo].[tbl_IDS_Kunden] WHERE [KdNrVERAG]=" & kdNr & " AND KdNrAlt =0 ORDER BY Zeitstempel DESC) order by [YearMonthDay], [Invoicenumber]" 'UTA Case 212 : SQL_STR = "SELECT " & IIf(cbxMax200Eintrage.Checked, " top 200 ", "") &