60 lines
1.7 KiB
VB.net
60 lines
1.7 KiB
VB.net
'Formula: IF_SKONTOBERECHNUNG
|
|
'Description: Skontoberechnung beim Beleg speichern
|
|
Function Formula ()
|
|
BELEGART_GUTSCHRIFT = 6
|
|
|
|
BruttoGesamt = Invoicing.CalcGrossAmount()
|
|
BelegNr = Value(0,39)
|
|
|
|
' Skonto% für BelegNr abfragen
|
|
SQL = "Select t2.c004 from t025 t (NOLOCK) join t226 t2 (NOLOCK) On t.c051 = t2.c010 where t2.c018 = 2 And t2.c004 > 0 And t.c055 = '"&BelegNr&"'"
|
|
Set Result = CWLStart.Connection.Select(SQL)
|
|
|
|
' Wenn es Zahlungskonditionen gibt
|
|
If Result.RowCount > 0 Then
|
|
Skonto = Result.Value("c004")
|
|
|
|
SkontoBetrag = BruttoGesamt * (Skonto / 100)
|
|
ZahlBetrag = BruttoGesamt - SkontoBetrag
|
|
|
|
' Wenn es einen Skonto% Wert gibt..
|
|
If Skonto > 0 Then
|
|
Value(0,121) = Cstr(Skonto)
|
|
Value(0,122) = FormatNumber(SkontoBetrag, 2)
|
|
Value(0,123) = FormatNumber(ZahlBetrag, 2)
|
|
|
|
UpdateOpBetrag ZahlBetrag
|
|
Else ' Wenn kein Skonto hinterlegt ist..
|
|
If BruttoGesamt >= 0 Then
|
|
UpdateOpBetrag BruttoGesamt
|
|
Else
|
|
If Value(25,35) = BELEGART_GUTSCHRIFT Then
|
|
UpdateOpBetrag BruttoGesamt
|
|
Else
|
|
UpdateOpBetrag 0
|
|
End If
|
|
End If
|
|
End If
|
|
Else ' Wenn es keine Zahlungskonditionen gibt..
|
|
UpdateOpBetrag BruttoGesamt
|
|
End If
|
|
|
|
Formula = 1 'successful
|
|
End Function
|
|
|
|
Function UpdateOpBetrag(Brutto, Grund)
|
|
' Wenn Rechnungsnummer noch nicht gefüllt ist (= Neuanlage Rechnung ohne Rechnen/Drucken).
|
|
If Len(Value(0,120)) = 0 Then
|
|
Do_UpdateOpBetrag Brutto, Grund
|
|
End If
|
|
|
|
' Wenn Zahldatum (= Valutadatum) noch nicht gefüllt ist.
|
|
'If Len(Value(25,73)) = 0 Then
|
|
' Do_UpdateOpBetrag(Brutto)
|
|
'End If
|
|
End Function
|
|
|
|
Function Do_UpdateOpBetrag(Brutto, Grund)
|
|
MsgBox "Neuer OPBetrag ist: " & Cstr(Brutto) & " (Brutto)"
|
|
Value(0,124) = FormatNumber(Brutto, 2)
|
|
End Function |